VC错误:term does not evaluate to a function是什么意思?是不是a是一个常对象,不能更新
来源:百度知道 编辑:UC知道 时间:2024/06/30 21:38:55
#include <iostream.h>
class A
{
public:
A(int i,int j)
{
x=i;
y=j;
}
void getx() const;
void gety() const;
private:
int x;
int y;
};
void A::getx() const
{
cout<<"x="<<x<<endl;
}
void A::gety() const
{
cout<<"y="<<y<<endl;
}
int main()
{
A const a(3,4);
a.getx();
a.gety();
a(5,6); //该行出现了这个错误
a.getx();
a.gety();
return 1;
}
class A
{
public:
A(int i,int j)
{
x=i;
y=j;
}
void getx() const;
void gety() const;
private:
int x;
int y;
};
void A::getx() const
{
cout<<"x="<<x<<endl;
}
void A::gety() const
{
cout<<"y="<<y<<endl;
}
int main()
{
A const a(3,4);
a.getx();
a.gety();
a(5,6); //该行出现了这个错误
a.getx();
a.gety();
return 1;
}
a 是 const,所以不可以在改变值
a(5,6);这样写本身也是不对的
这样不会调用其构造函数的
共一个对象的构造函数只会调用一次
你需要另加一个成员函数来设置x,y的值
比如
void Set( int i, int j)
{
x = i;
y = j;
}
或者采用
A* a= new A(3,4);
a = new A(5,6);
a(5,6);
他不是一个函数
VC错误:term does not evaluate to a function是什么意思?是不是a是一个常对象,不能更新
在程序中遇到error C2064: term does not evaluate to a function的错误,请问怎么翻译。
VC++中function does not take 9 parameters类似错误解答
c++里怎么会出现term does not evaluate to a function?
IIS出现class does not exist这个错误怎么解决
什么是E-term系统
does not have to
driver does not match
跪求quartusII 错误 Error: Current license file does not support the EP1C6Q240C8 device
This fil does not exist