Multiple Inheritance

前端 未结 4 912
离开以前
离开以前 2021-01-17 04:42
#include
using namespace std;

class A

{
   int a;
   int b;
   public:
   void eat()
   {
      cout<<\"A::eat()\"<

        
4条回答
  •  一整个雨季
    2021-01-17 05:12

    I don't think the static_cast will work.

    When you are on the foo function, all the compiler knows is that you have a pointer to A, whatever the type you passed as parameter.

    If you don't use virtual inheritance, then I think there is no way to call a B function from a pointer to A.

提交回复
热议问题