为什么会输出一堆意义不明的数字?而且判断if 也无法使用,求帮助

#include
using namespace std;
class cube
{
public:
void setlong(int m_l)
{
m_l = 1;
}
int getlong()
{
return m_l;
}
void setwide(int m_w)
{
m_w = 1;
}
int getwide()
{
return m_w;
}
void sethigh(int m_h)
{
m_h = 1;
}
int gethigh()
{
return m_h;
}
int calculates()
{
return 2 * m_l * m_w + 2 * m_l * m_h + 2 * m_w * m_h;
}
int calculatev()
{
return m_l * m_w * m_h;
}
private:
int m_l;
int m_w;
int m_h;
};
bool issame(cube &c1,cube &c2)
{
if (c1.getlong() == c2.getlong() && c1.getwide() == c2.getwide() && c1.gethigh() == c2.gethigh())
return true;
return false;
}
int main()
{
cube c1;
c1.setlong(10);
c1.sethigh(10);
c1.setwide(10);
cout <<"表面积:"<< c1.calculates() << endl;
cout << "体积:" << c1.calculatev() << endl;
cube c2;
c2.setlong(11);
c2.sethigh(11);
c2.setwide(11);
bool ret= issame(c1, c2);
if (ret)
{
cout << "they are same" << endl;
}
else
{
cout << "they are not same" << endl;
}
}

img

void setlong(int m_l)
{
m_l = 1;
}
改为
void setlong(int m)
{
m_l = m;
}
三个set函数都要这么改才行
不然你这些set函数根本没有达到修改类成员变量值的效果,自然输出都是乱码了。