You are on page 1of 2

// relation.cpp : Defines the entry point for the console application.

//

#include<iostream>
using namespace std;
class Battery
{
public:
Battery()
{
cout << "i am Battery Constructor" << endl;
}

void show()
{
cout << "I am Battery" << endl;
}
~Battery()
{
cout << "I am Battery Destructor" << endl;
}
};
class Engine
{
public:
Engine()
{
cout << "i am Engine Constructor" << endl;
}
void show()
{
cout << "I am Battery" << endl;
}
~Engine()
{
cout << "I am Engine Destructor" << endl;
}
};
class Vehicle
{
private:
Battery *bat;
Engine *eng;
public:

void show()
{
//Incase of Aggregation
bat = new Battery;
eng = new Engine;
}
Vehicle()
{
cout << "I am vehicle constructor" << endl;

}
~Vehicle()
{
cout << "I am Vehicle destructor" << endl;
}
};

int main()
{

Vehicle v;
v.show();
return 0;
}

You might also like