#include<iostream.h>
#include<conio.h>
#include<string.h>
class student
{
char name[20];
int roll;
public:
student()
{
cout<<"Default Constructor Called";
strcpy(name,"cpptute.blogspot.com");
roll=1;
}
student(char a[],int r)
{
cout<<"Parametrized Constructor Called";
strcpy(name,a);
roll=r;
}
student(student &s)
{
cout<<"Copy Constructor Called";
strcpy(name,s.name);
roll=s.roll;
}
~student()
{
cout<<"Destructor Called";
}
void display()
{
cout<<"Name :"<<name;
cout<<"\n Roll No. :"<<roll;
}
};
void main()
{
student s1;
s1.display();
student s2("Cpptute.blogspot.com",1);
s2.display();
student s3(s2);
s3.display();
getch();
}
#include<conio.h>
#include<string.h>
class student
{
char name[20];
int roll;
public:
student()
{
cout<<"Default Constructor Called";
strcpy(name,"cpptute.blogspot.com");
roll=1;
}
student(char a[],int r)
{
cout<<"Parametrized Constructor Called";
strcpy(name,a);
roll=r;
}
student(student &s)
{
cout<<"Copy Constructor Called";
strcpy(name,s.name);
roll=s.roll;
}
~student()
{
cout<<"Destructor Called";
}
void display()
{
cout<<"Name :"<<name;
cout<<"\n Roll No. :"<<roll;
}
};
void main()
{
student s1;
s1.display();
student s2("Cpptute.blogspot.com",1);
s2.display();
student s3(s2);
s3.display();
getch();
}