c++

constructor in c++

To initialize an object while creating it we need a constructor , we have sample program of constructor given below. Simple program using constructor in c++ #include using namespace std; class A{ public: A(int a,int b){ int c=a+b; cout<<“sum : “<<c; } }; int main(){ A obj(2,3); return 0; } Continue Reading