using namespace std;
class constructor
{
int p,q;
public:
constructor(int,int); //constructor declared
void output(void);
};
void constructor :: output(void)
{
cout<<"p = "<<p<<endl;
cout<<"q = "<<q<<endl;
}
constructor :: constructor(int x, int y) // constructor defined
{
p = x;
q = y;
}
int main()
{
constructor con(2,4); //constructor call
con.output();
return 0;
}
OUTPUT:
No comments:
Post a Comment