【发布时间】:2010-10-13 19:48:07
【问题描述】:
我已经开始为我需要的库编写一些代码。下面的代码给了我一个错误
class node {
public:
node() { }
node(const node&);
~node() { }
luint getID() { return this->ID; }
node& operator=(const node&);
protected:
luint ID;
std::vector<node*> neighbors;
};
node::node( const node& inNode) {
*this = inNode;
}
node& node::operator=(const node& inNode) {
ID = inNode.getID();
}
如下:
graph.cpp: 在成员函数'node& 节点::运算符=(常量节点&)': graph.cpp:16:错误:传递'const node'作为'luint'的'this'参数 node::getID()' 丢弃限定符
我的代码有什么问题吗?
谢谢,
【问题讨论】:
标签: c++ constants qualifiers