-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
64 lines (51 loc) · 1.39 KB
/
Copy pathmain.cpp
File metadata and controls
64 lines (51 loc) · 1.39 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
60
61
62
63
64
//
// Created by zhangrongxiang on 2017/10/22 0:00
// File main
//
#include <iostream>
#include "point.h"
#include "box.h"
using namespace std;
void box();
void pointer();
void person();
int main() {
// box();
// pointer();
person();
return 0;
}
void person() {
Person person("zing",23);
cout << "name : " << person.getName() << endl;
cout << "age : " << person.getAge() << endl;
person.setAge(22);
person.setName("zhangrongxiang");
cout << "name : " << person.getName() << endl;
cout << "age : " << person.getAge() << endl;
}
void pointer() {
Point M; //用定义好的类创建一个对象 点M
M.setPoint(10, 20); //设置 M点 的x,y值
M.printPoint(); //输出 M点 的信息
}
void box() {
Box Box1; // 声明 Box1,类型为 Box
Box Box2; // 声明 Box2,类型为 Box
double volume; // 用于存储体积
// box 1 详述
Box1.height = 5.0;
Box1.length = 6.0;
Box1.breadth = 7.0;
// box 2 详述
Box2.height = 10.0;
Box2.length = 12.0;
Box2.breadth = 13.0;
// box 1 的体积
volume = Box1.height * Box1.length * Box1.breadth;
cout << "Box1 的体积:" << volume << endl;
cout << "Box1 的体积:" << Box1.getVolume() << endl;
// box 2 的体积
volume = Box2.height * Box2.length * Box2.breadth;
cout << "Box2 的体积:" << volume << endl;
}