Hi, I declared it as below. it seem works both them
//subnode.cpp
class SubNode {
protected:
int _low, _high;
}
//node.cpp
class Node : SubNode {
........
int other;
friend std::ostream& operator<<(std::ostream& os, const Node& n) {
return os << "[" << n._low << "-" << n._high << "]";
}
};
//inline std::ostream& operator<<(std::ostream& os, /*const*/ Node& n) {
// return os << "[" << n.GETLOW() << "-" << n.GETHIGH() << "]";
// }
//end node.cpp
//subnode.cpp
class SubNode {
protected:
int _low, _high;
}
//node.cpp
class Node : SubNode {
........
int other;
friend std::ostream& operator<<(std::ostream& os, const Node& n) {
return os << "[" << n._low << "-" << n._high << "]";
}
};
//inline std::ostream& operator<<(std::ostream& os, /*const*/ Node& n) {
// return os << "[" << n.GETLOW() << "-" << n.GETHIGH() << "]";
// }
//end node.cpp
To copy to clipboard, switch view to plain text mode
Out of class 'const' gets error; idem for _low and _high that I coudn't access them because they are protected....
Bookmarks