First Constructor For Beginner

First Constructor For Beginner

Just open your c++ compiler Paste this code.



#include<iostream>
using namespace std;
class ali
{
public :
int a,b;
ali( )
{
cout<<"Hello guys i am const\n";
cout<<"Enter 1st Number";
cin>>a;
cout<<"Enter 2st Number";
cin>>b;
}
void callfun()
{

cout << "Answer is "<<a+b;
}

};
int main()
{
ali m;
m.callfun();

}

0 comments: