C
christopher diggins
Hi everyone,
I have the following code (greatly simplified to demonstrate issue) :
#include <iostream>
class CBaseFuBar {
public:
virtual void Fu() { std::cout << "base"; };
};
class CDerivedFuBar : public CBaseFuBar {
public :
virtual void Fu() { std::cout << "derived"; };
};
typedef void (CBaseFuBar::*FuFxnPtr)();
int main() {
CDerivedFuBar fubar;
FuFxnPtr fxn;
fxn = &CBaseFuBar::Fu;
(fubar.*fxn)(); // prints out "derived" not "base" like I want
std::cin.get();
return 0;
};
The problem is that given CDerivedFuBar I want to get a member function
pointer to refer to the base Fu function and not automatically get resolved
to the derived Fu function. The CBaseFuBar class can not be modified, but
the CDerivedFuBar class can be. Thanks in advance!
I have the following code (greatly simplified to demonstrate issue) :
#include <iostream>
class CBaseFuBar {
public:
virtual void Fu() { std::cout << "base"; };
};
class CDerivedFuBar : public CBaseFuBar {
public :
virtual void Fu() { std::cout << "derived"; };
};
typedef void (CBaseFuBar::*FuFxnPtr)();
int main() {
CDerivedFuBar fubar;
FuFxnPtr fxn;
fxn = &CBaseFuBar::Fu;
(fubar.*fxn)(); // prints out "derived" not "base" like I want
std::cin.get();
return 0;
};
The problem is that given CDerivedFuBar I want to get a member function
pointer to refer to the base Fu function and not automatically get resolved
to the derived Fu function. The CBaseFuBar class can not be modified, but
the CDerivedFuBar class can be. Thanks in advance!