CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

Can Derived Class Contain Vector of pointers to the parent class? topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2010, 12:23 AM
Junior Member
 
Join Date: Jul 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ZhiYi is on a distinguished road
| More
Post Can Derived Class Contain 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:
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Logger Class in C++ senseiwa C++ Programming 0 06-28-2010 08:16 AM
Pointer and Class inspiration C++ Programming 8 05-31-2010 08:55 PM
How to enforce a virtual fn is overloaded by derived class? Alex C++ Programming 0 04-12-2009 07:31 AM
get Class johny10151981 Win32 Programming 1 10-07-2008 03:58 AM
changing variable types of a function of a derived class mrclash C# Programming 0 09-20-2006 04:56 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 02:57 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board