-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheretance.cpp
More file actions
52 lines (42 loc) · 1.5 KB
/
Inheretance.cpp
File metadata and controls
52 lines (42 loc) · 1.5 KB
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
47
48
49
50
51
52
#include <iostream>
#include <vector>
#include <string>
class Car
{
private:
std::string m_brand;
std::string m_model;
int m_manufacture_year;
public:
Car(std::string brand, std::string model, int manufacture_year)
: m_brand { brand }, m_model { model }, m_manufacture_year { manufacture_year }
{
}
std::string get_brand() { return m_brand; }
std::string get_model() { return m_model; }
int get_manufacture_year() { return m_manufacture_year; }
void set_brand(std::string brand) { m_brand = brand; }
void set_model(std::string model) { m_model = model; }
void set_manufacture_year(int year) { m_manufacture_year = year; }
};
class SuperSportsCar : public Car
{
private:
bool m_has_batmobile_thrusters;
std::string m_custom_bodykit_brand;
std::vector<std::string> m_sponsor_stickers;
public:
SuperSportsCar(std::string brand, std::string model, int manufacture_year,
bool b_has_batmobile_thusters, std::string bodykit_brand, std::vector<std::string> stickers)
: Car(brand, model, manufacture_year), m_has_batmobile_thrusters { b_has_batmobile_thusters }, m_custom_bodykit_brand { bodykit_brand }, m_sponsor_stickers { stickers }
{
}
};
int main()
{
SuperSportsCar bumblebee("Camaro", "Chevrolet", 1977, true, "Custom fainted", { "Autobot logo" });
std::cout << bumblebee.get_brand() << std::endl;
std::cout << bumblebee.get_model() << std::endl;
std::cout << bumblebee.get_manufacture_year() << std::endl;
return 0;
}