Originally Posted by
audinue
I just figure it out this is as a matter of package/unit visibility, since C++ is stupid enough to know that but straightforward name collision solver namespaces.
The second part of your sentence is unintelligible to me. This is just a matter of language rules depending on how language designers interpret theory and consider practice. I tend to think that C++'s interpretation is unnecessarily strict since the damage is done anyway once you have non-private member variables, but that does not mean that C++ "isn't mature enough to handle high level OOP concepts". You really should stop making such troll-like comments until you are more mature in your understanding of the programming language that you are commenting on.
Originally Posted by
audinue
However the problem can be solved in nasty way(which maybe possible in C++): If and if only there is an ability to access parameter's base class to call the non-overriden method -- IF the parameter IS LinkedNode, otherwise we don't care.
The "access parameter's base class to call the non-overriden method" part is easy:
Code:
virtual void setNext(Node *next) {
if(next) {
next->Node::setPrevious(this);
}
Node::setNext(next);
}
If you actually want to have it behave depending on the actual type of the object that the next parameter points to, then you will incur the runtime penalty of a type check:
Code:
virtual void setNext(Node *next) {
if(next && dynamic_cast<LinkedNode*>(next) == 0) {
next->setPrevious(this);
}
Node::setNext(next);
}