Practical 19
#include<iostream>
using namespace std;
class Gajjar
{
int id;
public:
Gajjar()
{}
Gajjar(int a)
{
id = a;
}
Gajjar(Gajjar &x)
{
id = x.id;
}
void display()
{
cout<<id;
}
};
int main()
{
Gajjar A(100);
Gajjar B(A);
GajjarC=A;
GajjarD;
D=A;
cout<<"\n Id of A: ";
A.display();
cout<<"\n Id of B: ";
B.display();
cout<<"\n Id of C: ";
C.display();
cout<<"\n Id of D: ";
D.display();
return 0;
}
output:
A : 100
B : 100
C : 100
D : 100
using namespace std;
class Gajjar
{
int id;
public:
Gajjar()
{}
Gajjar(int a)
{
id = a;
}
Gajjar(Gajjar &x)
{
id = x.id;
}
void display()
{
cout<<id;
}
};
int main()
{
Gajjar A(100);
Gajjar B(A);
GajjarC=A;
GajjarD;
D=A;
cout<<"\n Id of A: ";
A.display();
cout<<"\n Id of B: ";
B.display();
cout<<"\n Id of C: ";
C.display();
cout<<"\n Id of D: ";
D.display();
return 0;
}
output:
A : 100
B : 100
C : 100
D : 100
No comments:
Post a Comment