#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
class emp
{
public:
int emp_id;
int sal;
char name[20];
emp(int a,int b,char c[20])
{
emp_id=a;
sal=b;
strcpy(name,c);
cout<<"normal constructor\n"<<emp_id<<"\n"<<sal<<"\n"<<name<<"\n";
}
emp(emp&E)
{
emp_id=E.emp_id;
sal=E.sal;
strcpy(name,E.name);
cout<<"copy constructor\n"<<(2*emp_id)<<"\n"<<(2*sal)<<"\n"<<name;
}
};
void main()
{
clrscr();
int id,sal;
char ename[20];
cout<<"enter the id\n";
cin>>id;
cout<<"enter the sal\n";
cin>>sal;
cout<<"enter the name\n";
gets(ename);
emp E(id,sal,ename);
emp E1(E);
getch();
}
#include<conio.h>
#include<string.h>
#include<stdio.h>
class emp
{
public:
int emp_id;
int sal;
char name[20];
emp(int a,int b,char c[20])
{
emp_id=a;
sal=b;
strcpy(name,c);
cout<<"normal constructor\n"<<emp_id<<"\n"<<sal<<"\n"<<name<<"\n";
}
emp(emp&E)
{
emp_id=E.emp_id;
sal=E.sal;
strcpy(name,E.name);
cout<<"copy constructor\n"<<(2*emp_id)<<"\n"<<(2*sal)<<"\n"<<name;
}
};
void main()
{
clrscr();
int id,sal;
char ename[20];
cout<<"enter the id\n";
cin>>id;
cout<<"enter the sal\n";
cin>>sal;
cout<<"enter the name\n";
gets(ename);
emp E(id,sal,ename);
emp E1(E);
getch();
}
No comments:
Post a Comment