|
-
July 1st, 2010, 02:58 PM
#1
Can a derived class contain a vector of pointers to the parent class?
Lets say I have a parent class called:
class Car
{
.....
};
Then there is a derived class called Toyota, which has a method returning a pointer to the parent class and a vector of pointers of the parent class.
class Toyota : class Car
{
public:
*Car GetCar(char* model);
private:
std::vector<Car*> cars;
};
Is this allowed?
I came across this programming question which requests for a class and a derived class where the derived class has a container of pointers to the parent class and individual elements of the container has to be accessed quickly.
(This question is neither a school assignment nor a test)
:s11:
Last edited by ZhiYi; July 1st, 2010 at 03:02 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|