#include<iostream>
#include<string>
using namespace std;
class cube{
public :
//设置长
void setM(int m){
M_l = m;
}
int getl(){
return M_l;
}
//设置宽
void setr(int r){
M_r = r;
}
int get(){
return M_r;
}
//设置高
void setm(int m){
M_m = m;
}
int getm(){
return M_m;
}
//立方体设置面积
int mianji(){
return M_l*M_r * 2 + M_r*M_m * 2 + M_l*M_m * 2;
}
//立方体体积
int tiji(){
return M_l*M_r*M_m;
}
bool panduan(cube p1){
if (M_l == p1.getl() && M_r == p1.getm() && M_m == p1.get())
return true;
return false;
}
private :
int M_l;//长
int M_r;//宽
int M_m;//高
};
//全局函数判断是否相等
bool panduan(cube p, cube p1){
if (p.getl() == p1.getl() && p.getm() == p1.getm() && p.get() == p1.get())
return true;
return false;
}
int main(){
cube p;
//第一个立方体
p.setM(10);
p.setm(10);
p.setr(10);
//输出面积600
cout << p.mianji() << endl;
//输出体积1000
cout << p.tiji() << endl;
//设置第二个立方体
cube p1;
p1.setM(10);
p1.setm(10);
p1.setr(10);
cout << "局部变量判断" << endl;
if (p1.panduan(p1))cout << "两个立方体相等" << endl;
else cout << "两个立方体不相等" << endl;
bool c=panduan(p, p1);
cout << "全局变量判断" << endl;
if (c == true) cout << "两个立方体相等" << endl;
else cout << "两个立方体不相等" << endl;
system("pause");
return 0;
}