Link to home
Start Free TrialLog in
Avatar of kennysflau
kennysflau

asked on

Inaccessible base??

I have 4 files named "Animal.h", "Bird.h", "Canary.h" and "main.cpp" as shown below. When I compile, it tells me that "Animal is an inaccessible base of "Canary"... what does the problem come from?

#ifndef ANIMAL_H
#define ANIMAL_H
#include <iostream>
using namespace std;

class ANIMAL{      
     public:
             inline ANIMAL();
             virtual void talk(void) const = 0;
};

inline ANIMAL::ANIMAL()
{
}
#endif

#ifndef BIRD_H
#define BIRD_H
#include "Animal.h"

class BIRD : ANIMAL{
      public:
             inline BIRD();
             virtual void talk(void) const = 0;
};

inline BIRD::BIRD()
{
}
#endif

#ifndef CANARY_H
#define CANARY_H
#include "Bird.h"

class CANARY : public BIRD{
      public:
             inline CANARY();
             inline virtual void talk(void) const;
};

inline CANARY::CANARY()
{
}

inline void CANARY::talk(void) const{
       cout << "I am Canary" << endl;
}
#endif

#include <iostream>
#include "Animal.h"
#include "Canary.h"
using namespace std;

int main(void)
{
    ANIMAL *pets[1];
    pets[0] = new CANARY;
    pets[0]->talk();
    return 0;
}
SOLUTION
Avatar of Axter
Axter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, change

class BIRD : ANIMAL{

to


class BIRD :public ANIMAL{


---
Harish
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial