-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.cpp
More file actions
59 lines (44 loc) · 1.02 KB
/
Copy pathstruct.cpp
File metadata and controls
59 lines (44 loc) · 1.02 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
53
54
55
56
57
58
59
#include <cstdio>
#include <string>
using namespace std;
struct Adress {
string city;
string post;
};
struct Empolyee {
string name;
Adress workAdress;
Adress homeAdress;
void printInfo() {
printf("name: %s, work at: %s, home at: %s. \n", name.c_str(),
workAdress.post.c_str(), homeAdress.post.c_str());
}
};
struct Car {
string model;
int speed;
string type;
struct Engine {
int power;
int force;
} engine;
void boostSpeed() {
speed = 300;
printf("Speed Bootsted! now, the speed is %i km/hr. \n", speed);
}
void getData() {
printf("model: %s, speed: %i km/hr, type: %s, engine power: %i, engine "
"force: %i. \n",
model.c_str(), speed, type.c_str(), engine.power, engine.force);
}
};
int main() {
Car SkyBlue = {"SkyBlue", 200, "Sports", {200, 100}};
Car *myCar = &SkyBlue;
myCar->getData();
myCar->boostSpeed();
Adress home = {"A.A", "mexico"};
Empolyee amn = {"amn", {"A.A", "kore"}, home};
amn.printInfo();
return 0;
}