-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.cpp
More file actions
46 lines (41 loc) · 937 Bytes
/
Car.cpp
File metadata and controls
46 lines (41 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
using std::cout;
using std::endl;
#include "Car.h"
//constructor using vehicle constructor
Car::Car( const int identity, const int theyear, const string& colorful, const int miles, const int eng, const string& ga, const int pol)
: Vehicle(identity, theyear, colorful, miles)
{
//sets new things according to parameter
engine = eng;
gas = ga;
poll = pol;
}
//getters
int Car::getengine() const
{
return engine;
}
string Car::getgas() const
{
return gas;
}
int Car::getpoll() const
{
return poll;
}
//print method overloading
void Car::print() const
{
cout << "{{{printing car}}}" << endl;
cout << "Engine: "<< getengine() <<endl;
cout << "Gas: " << getgas() << endl;
cout << "Pollution: " << getpoll() << endl;
//calls vehicle's print
Vehicle::print();
}
//operator overloading
ostream &operator<<( ostream &output, const Car &c)
{
c.print();
}