so basically in templates inheritance stops working.
three ways around this :
prefix calls to base class functions with this-> ( why does it work ?...as in how does it work underneath?)
use a using declaration e,g,
template
class logginmsgsender:public msgsender
public:
using msgsender
void sendclearmsg(msginfo& info)
{
sendClear(info);
}
};
or you can exactly specify the function being called in the base class as in
msgsendder
its least desirable because if senclear is virtual than the effect of virtual is lost
note that all of these solutions basically promise the compiler that the definition of the function will be available, and so when it sees a call to senclearmsg and if it found that the expected function is not available, then it will still give you a compiler error.
so basically the availablity of a function call or something else is checked only when its usage is encountered.....so if i declare a class that doesnt define sendclear function but neither uses sendclearmsg function than it will compile and execute without error ? is that right ?
things to remember:
in derived class templates refer to names in base class templates via a this->prefix via using declarations or via an explicit base class qualification.
No comments:
Post a Comment