#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);//输出面积600cout << p.mianji() << endl;//输出体积1000cout << 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;
}