class animal {
public:
animal() {
cout << "An animal is in da house.\n";
}
virtualvoid Roar();
};
void animal::Roar() {
cout << "*insert roar*\n";
}
class bear : public animal {
bear() : animal() {
cout << "A bear is in da air";
}
void Roar();
};
void bear::Roar() {
cout << "GRRRRR!\n";
}
void letsRoar(animal * someAni) {
someAni->Roar();
}
int main() {
bear grizzly;
animal * PointBearer = &grizzly;
letsRoar(PointBearer);
return 0;
}
Output from visual studio
2 IntelliSense: "bear::bear()" (declared at line 21) is inaccessible c:\Users\Cameron\Documents\Visual Studio 2013\Projects\JustForFun\JustForFun\Source.cpp 36 7 JustForFun
Error 1 error C2248: 'bear::bear' : cannot access private member declared in class 'bear' c:\users\cameron\documents\visual studio 2013\projects\justforfun\justforfun\source.cpp 36 1 JustForFun