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;
}
kennysflauAsked:
Who is Participating?
 
Harisha M GCommented:
kennysflau, eventhough you are deriving CANARY from BIRD as public, the class BIRD is derived from ANIMAL as private (default). So, ANIMAL is inaccessible to CANARY class
0
 
AxterCommented:
Hi kennysflau,
> class BIRD : ANIMAL{

The above line needs pulic declaration for derived ANIMAL
Exampl:
class BIRD : public ANIMAL{


Cheers!
0
 
Harisha M GCommented:
Hi, change

class BIRD : ANIMAL{

to


class BIRD :public ANIMAL{


---
Harish
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.