Hi,
I know it isn't used but for completness....Why compiler says I can't instantiate it? I've publicized it in the derived class; doesn't it should work?
Qt Code:
  1. Pet* p = new Cat;
  2. #ifndef PET2_H
  3. #define PET2_H
  4. using std::string;
  5. using std::cout;
  6. class Pet {
  7. public:
  8. Pet() { speak(); cout << "Pet::Pet()\n"; }
  9. virtual ~Pet() = 0;
  10. virtual string speak() { return "Pet "; }
  11. };
  12. inline Pet::~Pet() { speak(); cout << "Pet::~Pet()\n"; }
  13. class Cat : private Pet {
  14. char* _ver;
  15. public:
  16. Pet::Pet;
  17. Cat() : _ver( new char('q') /* 1 */ ) { cout << "Cat::Cat()\n";}
  18. ~Cat() { cout << "Cat::~Cat()\n"; delete _verso; }
  19. string speak() { return "Cat: bark, bark\n"; }
  20. };
  21. #endif PET2_H
  22. error C2243: 'type cast' : conversion from 'Cat *' to 'Pet *' exists, but is inaccessible
To copy to clipboard, switch view to plain text mode 
furthermore: in /* 1 */ i'd like to initialize with a string. Which sintax, please?