#include<iostream.h>
#include<conio.h>
class emp
{
private:
int eno;
char *s;
float sal;
public:
emp()
{
eno=10;
s="ravi";
sal=1500.20f;
}
void show();
};
void emp::show()
{
cout<<eno<<"\t"<<s<<"\t"<<sal<<endl;
}
class demo
{
private:
int *a;
char *b;
emp *c;
public:
demo()
{
a=new int[3];
b=new char[4];
c=new emp();
}
void getdata();
void display();
~demo()
{
delete []a;
delete []b;
delete c;
cout<<"demo class destructor executed\n";
}
};
void demo::getdata()
{
cout<<"enter integer values\n";
for(int i=0;i<=2;i++)
cin>>a[i];
cout<<"enter any 3 characters\n";
for(int j=0;j<=2;j++)
cin>>b[j];
}
void demo::display()
{
for(int i=0;i<=2;i++)
{
cout<<a[i]<<"\t";//<<endl;
}
for(int j=0;j<=3;j++)
{
cout<<b[i]<<"\t"<<endl;
}
emp e;
e.show();
}
void main()
{
demo obj;
clrscr();
obj.getdata();
obj.display();
getch();
}
#include<conio.h>
class emp
{
private:
int eno;
char *s;
float sal;
public:
emp()
{
eno=10;
s="ravi";
sal=1500.20f;
}
void show();
};
void emp::show()
{
cout<<eno<<"\t"<<s<<"\t"<<sal<<endl;
}
class demo
{
private:
int *a;
char *b;
emp *c;
public:
demo()
{
a=new int[3];
b=new char[4];
c=new emp();
}
void getdata();
void display();
~demo()
{
delete []a;
delete []b;
delete c;
cout<<"demo class destructor executed\n";
}
};
void demo::getdata()
{
cout<<"enter integer values\n";
for(int i=0;i<=2;i++)
cin>>a[i];
cout<<"enter any 3 characters\n";
for(int j=0;j<=2;j++)
cin>>b[j];
}
void demo::display()
{
for(int i=0;i<=2;i++)
{
cout<<a[i]<<"\t";//<<endl;
}
for(int j=0;j<=3;j++)
{
cout<<b[i]<<"\t"<<endl;
}
emp e;
e.show();
}
void main()
{
demo obj;
clrscr();
obj.getdata();
obj.display();
getch();
}
No comments:
Post a Comment