这个输出结果是为啥呢?求助!!!
#include <iostream>
using namespace std;
class A
{
private:
int w,h;
public:
int getValue() const;
int getValue();
A(int x,int y)
{
this->h=x;
this->w=y;
}
A()
{}
};
int A::getValue() const
{
cout<<"with const"<<endl;
return w*h;
}
int A::getValue()
{
cout<<"with none const"<<endl;
return w*h;
}
void main()
{
A const a(3,4);
A b(3,6);
cout<<a.getValue()<<endl;
cout<<b.getValue()<<endl;
}
这个代码的输出结果为:
wi th const
12
with none const
18
但是将代码中的
cout<<a.getValue()<<endl;
cout<<b.getValue()<<endl;修改为
cout<<a.getValue()<<endl<<b.getValue()<<endl;
输出结果则变为:
with none const
with const
12
18
为什么输出结果会变成这个样子呢?
相关推荐
雷尼绍球杆仪数据怎么看 求助!!!
求助!!!测试的时候是让球杆仪逆时针转两圈,然后顺时针转两圈,得到的源文件如下为什么有这么多组数据,我该用哪一个啊??? 100 100 0 360 180 100 X Y CCW CW -0.1 0.1 -0.1 0.1 90 110 1 3.97887357729738 0 lcw 20200108-220206 20200108-222316 Renishaw QC20-W 064J33 1 064J33-130813-00 20130813 Renishaw Renishaw Ballbar 20 5.09.05.03 CCW 20.0 626 1876 3.984 -
Stata结果输出_stata结果输出_
stata的输出结果,stata操作完成后怎么把结果输出到word或者excel
收费网站破解!!!职业黑格的解说!!!
收费网站破解!!!职业黑格的解说!!!想成为高手吗?千万不要错过!!!
什么是模式?什么是框架?为你详细解答,come on!!!
什么是模式?什么是框架?为你详细解答,come on!!!
如何把ORACLE的查询结果输出成TXT文件
如何把ORACLE的查询结果输出成TXT文件.docx


