问题描述:

I am trying to construct a class with three subclasses, and then creating an object of these subclasses. This is what I am doing so far,

 class Car{

class Red{

public:

... //functions

};

class Blue{

public:

... //functions

};

class Red{

public:

... //functions

};

};

I am having trouble creating an object of the class red. I tried doing this:

Car*redCar;

redCar = new Red;

But it does not work. Any ideas?

网友答案:
Car::Red redCar;

Assuming that Red is public.

Get a book on C++!

相关阅读:
Top