X
xtrigger303
Hi to all,
a newbie question. Is it possible to avoid the virtual mechanism with
pointers to members syntax the same way it's done with an explicit
call ( obj.Base::Func() )? It would be useful for something I'm
doing... check out the trivial program down here...
Thanks in advance,
Francesco
#include <iostream>
struct Base
{
virtual ~Base() {}
virtual void Do() const { std::cout << "Base\n"; }
};
struct Der : public Base
{
virtual void Do() const { std::cout << "Der\n"; }
};
int main()
{
Der obj;
obj.Base:o(); // avoid virtual call
void ( Base::*ptrToMembFunc )() const = &Base:o;
( obj.*ptrToMembFunc )(); // virtual call
// is there a way to avoid virtual call with pointers to member
functions
// as in the above direct call?
}
a newbie question. Is it possible to avoid the virtual mechanism with
pointers to members syntax the same way it's done with an explicit
call ( obj.Base::Func() )? It would be useful for something I'm
doing... check out the trivial program down here...
Thanks in advance,
Francesco
#include <iostream>
struct Base
{
virtual ~Base() {}
virtual void Do() const { std::cout << "Base\n"; }
};
struct Der : public Base
{
virtual void Do() const { std::cout << "Der\n"; }
};
int main()
{
Der obj;
obj.Base:o(); // avoid virtual call
void ( Base::*ptrToMembFunc )() const = &Base:o;
( obj.*ptrToMembFunc )(); // virtual call
// is there a way to avoid virtual call with pointers to member
functions
// as in the above direct call?
}