Multiple Inheritance

前端 未结 4 914
离开以前
离开以前 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:16

    First of all, obj does not have a member named B. It Inherits from B, which means that it inherits all of B's members as its own.

    You can call:

    foo(static_cast(&obj));
    to make it work.

提交回复
热议问题