What's wrong?

Posts 1–7 of 7 · Page 1 of 1
What's wrong?
Code:
error C2243: 'type cast' : conversion from 'White *' to 'Human *' exists, but is inaccessible
classes.h
[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]
[php]
class White : public Human
[/php]
Ohh. Thankyou
Daum guy, pay more attention to the book.
Roger that /yea
I think void should become minion here lol
request close is request
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us