#include <iostream>
#include <string.h>
using namespace std;
class A{
int *id;
string
name;
string address;
float *salary;
public:
A (int x =0, string n="unknown" ,string ad
="city=unknown country =unknown ",float s=0 ) {
id = new int;
*id =x;
name = n;
address=ad ;
salary =new float;
*salary =s; }
~A()
{
cout<<"\t\t\tThe destroctor
of: " <<endl;
cout<<"Id is : "<<*id <<endl;
cout<<"Name : "<<name <<endl;
cout<<"Address :
"<<address <<endl;
cout<<"Salary : "<<*salary <<endl; }
void display () {
cout<<"The id is :
"<<*id <<endl;
cout<<"The Name is : "<<name <<endl;
cout<<"The Address is : "<<address <<endl;
cout<<"The Salary is : "<<*salary <<endl; }};
int main() {
A u1;
A u2(1,"hunnan");
A u3(1,"hunnan
malik","City =rwl pindi",50000.0);
u1.display();
u2.display();
u3.display();
return 0; }
Output:
Comments
Post a Comment