Я начал писать код для библиотеки, в которой я нуждаюсь. Следующий код дает мне ошибкуC++ qualifier error
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: In member function 'node& node::operator=(const node&)': graph.cpp:16: error: passing 'const node' as 'this' argument of 'luint node::getID()' discards qualifiers
Я сделал ничего плохого с кодом?
Спасибо,
Следующие две ссылки могут быть interessting для вас: http://en.wikipedia.org/wiki/Const-correctness и http://www.parashift.com/c++-faq -lite/const-correctness.html – Vinzenz