This Study Resource Was
This Study Resource Was
This Study Resource Was
Implement the classes according to the given class diagram. It shows both the composition
and aggregation relationships.
[Note: consider the necessary data members, constructors, destructors and member functions
accordingly]
m
er as
co
eH w
o.
rs e
ou urc
#include<iostream>
#include<string>
using namespace std;
o
class Vehicle
aC s
{
v i y re
private:
string type;
string company;
string model;
Engine e;
ed d
public:
ar stu
}
Th
~Vehicle()
{
cout << "Vehicle Destroyed" << endl;
}
void print()
{
cout << "Vehicle type " << type << endl;
cout << "Vehicle Compnay " << company << endl;
cout << "Vehicle Model " << model << endl;
}
};
class Driver
{
private:
This study source was downloaded by 100000822924914 from CourseHero.com on 04-06-2021 15:20:01 GMT -05:00
https://www.coursehero.com/file/64599086/OOP-21docx/
string Type;
string name;
int age;
Vehicle *c;
public:
Driver(Vehicle *ob) :c(ob)
{
m
class Engine
er as
{
co
private:
eH w
int number;
string lifetime;
o.
string company; rs e
public:
Engine()
ou urc
{}
Engine(int n, string l, string c) :number(n), lifetime(l), company(c)
{
o
}
ar stu
};
int main()
{
Vehicle vobj("Car", "Honda", "2020");
sh is
vobj.print();
Driver *dobj = new Driver(&vobj);
Th
This study source was downloaded by 100000822924914 from CourseHero.com on 04-06-2021 15:20:01 GMT -05:00
https://www.coursehero.com/file/64599086/OOP-21docx/
Powered by TCPDF (www.tcpdf.org)