#include<iostream.h>
#include<conio.h>
class A
{
public:
int a, b;
A()
{
a=5;
b=10;
}
void display()
{
cout<<"Display"<<endl;
}
};
class B
{
public:
int c;
A ob; //If a class has an object of another class as a Data Member
//It called has-a relationship or aggregation.
void show()
{
//A ob;
cout<<ob.a+ob.b<<endl;
c=11;
cout<<c<<endl;
ob.display();
}
};
main()
{
clrscr();
B ob;
ob.show();
getch();
return 0;
}
No comments:
Post a Comment