/*parameterized constructure
****************************/
#include<iostream>
using namespace std;
class test
{
private:
int a,b;
public:
test(int x,int y) // here we passing the parameter to constructure
{
a=x;
b=y;
}
void display()
{
cout<<"value of a:"<<a<<endl;
cout<<"value of b:"<<b<<endl;
}
};
int main()
{
int x,y;
cout<<"please enter a first number:";
cin>>x;
cout<<"please enter the second number:";
cin>>y;
test t(x,y);
t.display();
}
No comments:
Post a Comment