bitplane wrote:if i make a "newclass" derived from "myclass" and override function(), myclass::function() will call myclass::function(), but this->function() will call newclass::function().
also, i dont think there's any difference between "this->function()" and "function()"
That's not right, because the functions are not virtual.
this->function(),
function(), and
myclass::function() do all the same.
When you want to have the behaviour bitplane described, then you have to make the member function
function() virtual.
@olivehehe_03,
myclass::function() is a member function, you need an instance of myclass to call this function, so just calling myclass::function(); won't work, because this function is not static.
@eneru, it's a taste question, but most C++ coding styles don't use
this explicitly in cases it is clear. Calling member functions inside other member functions on the same instance is more or less the default case. Instead use of other functions should be made obvious. Like when calling a function in global space to call it this way ::myglobalfunction() or when it is inside a namespace prepend it with the namespace. This is more helpful to a reader of the source code, as it carries more informations.