What's wrong?
Code:
error C2243: 'type cast' : conversion from 'White *' to 'Human *' exists, but is inaccessible
[php]#include <iostream>
using namespace std;
class Human
{
public:
Human();
virtual ~Human();
virtual void Speak()const { "Human Speak\n"; }
};
class White : Human
{
public:
void Speak()const { "White man speak\n"; }
};
class Black : Human
{
public:
void Speak()const { "Black man speak\n"; }
};
class Mexican : Human
{
public:
void Speak()const { "Mexican man speak\n"; }
};
class Asian : Human
{
public:
void Speak()const { "Asian man speak\n"; }
};[/php]
Main.cpp:
[php]#include "classes.h"
int main()
{
Human *ptr;
Human *speak[5];
char choice;
for(int i=0; i<10; i++)
{
cout << "(W)hite (B)lack (M)exican (A)sian\n";
cin >> choice;
switch(choice)
{
case 'w':
ptr = new White;
break;
case 'b':
ptr = new Black;
break;
case 'm':
ptr = new Mexican;
break;
case 'a':
ptr = new Asian;
break;
default:
ptr = new Human;
break;
}
speak[i] = ptr;
}
for (int i=0;i<5;i++)
{
speak[i]->Speak();
}
}[/php]

