Thursday, May 7, 2009
Parameterized Constructor
In constructor can use argument also, the argument values can be passed from the main program. This type of constructors called parameterized constructor.
header files
class num
{
int a,b;
public:
num(int x, int y)// Parameterized constructor
{
a=x;
b=y;
}
void display()
};
void num::display()
{
cout<
cout<
}
void main()
{
num obj(1000,5000);
obj.display();
}
Output will be
1000
5000
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
[フレーム]