WAP to understand the constructor
#include<iostream.h>
#include<conio.h>
class code
{
public:
int id;
code()
{
id=0;
}
code (int a)
{
id=a;
}
code (code &x)
{
id=x.id;
}
void display()
{
cout<<"
id="<<id;
}
};
void main()
{
// int a;
// cout<<"
enter number :";
// cin>>a;
code c;
c.display();
code d(50);
d.display();
code c1);
c1.display();
getch();
clrscr();
}
No comments:
Post a Comment