You are on page 1of 2

House Aggregation - Example

============================================
#include <stdlib.h>
#include <string.h>
#include <iostream.h>

class Window{
public:
Window(){}
Window(int s){size=s;cout<<"\nWindow is Created";}
int getSize(){return size;}
private:
int size;
};

class Door{
public:

Door(){}
Door(char *dt){strcpy(doorType,dt);cout<<"\nDoor is
Created";}
char *getDoorType(){return doorType;}
private:
char doorType[20];
};

class Wall{
public:
Wall(){}
Wall(int l){length=l;cout<<"\nWall is Created";}
int getWallLength(){return length;}

private:
int length;
};

class House{
public:
House(){}
House(int s,char *dt,int l):wi(s),d(dt),wa(l){cout<<"\nHosue
is Created";}

void Print()
{
cout<<"\n\n================================
============================================
====";
cout<<"\nSize of Window is: "<<wi.getSize()<<" inch";
cout<<"\nType of Door is: "<<d.getDoorType();
cout<<"\nLength of Wall is: "<<wa.getWallLength()<<"
feet";

cout<<"\n\n================================
============================================
====\n";

}
private:
Window wi;
Door d;
Wall wa;
};

void main()
{
int s,l;
char t[20];
cout<<"\nEnter the Size of Window: ";
cin>>s;
cout<<"\nEnter the Type of Door: ";
cin>>t;
cout<<"\nEnter the Length of Wall: ";
cin>>l;
system("cls");
House h(s,t,l);
h.Print();
cout<<endl;
}

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006