I may not be understanding private inheritance right, but I thought when you inherited privately that you could still access public member data/functions, but the child class of the derived class would not. For some reason it is saying the public print() method is not accessable in this context....Is there something I'm doing wrong?
#include <iostream>
#include <cstdlib>
class Animal
{
public:
Animal() { std::cout << "Animal Constructor....\n"; }
virtual ~Animal() { std::cout << "Animal Deconstructor...\n"; }
void print() const { std::cout << "Print method...\n"; }
private:
void printP() const { std::cout << "Private print method...\n"; }
};
class Dog : public Animal
{
public:
Dog() { std::cout << "Dog constructor...\n"; }
~Dog() { std::cout << "Dog deconstructor..\n"; }
};
class Bird : private Animal
{
public:
Bird() { std::cout << "Bird constructor...\n"; }
~Bird() { std::cout << "Bird deconstructor...\n"; }
};
int main()
{
Bird b;
b.print();
}