Click here to Skip to main content
15,914,357 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: programmically calling .exe Pin
Navin29-Apr-04 8:16
Navin29-Apr-04 8:16 
GeneralRe: programmically calling .exe Pin
softp_vc30-Apr-04 23:27
softp_vc30-Apr-04 23:27 
GeneralLink Error with DLL Pin
sweep12329-Apr-04 5:42
sweep12329-Apr-04 5:42 
GeneralRe: Link Error with DLL Pin
David Crow29-Apr-04 7:56
David Crow29-Apr-04 7:56 
GeneralRe: Link Error with DLL Pin
sweep12329-Apr-04 21:29
sweep12329-Apr-04 21:29 
Generalsetlocale() only working second time around Pin
BlueShirtPaul29-Apr-04 5:31
BlueShirtPaul29-Apr-04 5:31 
GeneralRe: setlocale() only working second time around Pin
Navin29-Apr-04 6:15
Navin29-Apr-04 6:15 
Generalduplicating derived classes Pin
Jerome Conus29-Apr-04 5:28
Jerome Conus29-Apr-04 5:28 
Hi !

I've a C++ question regarding the copy constructor.

Here is my example :

Let's say I've a class which contains a list of pointer on Polygons, called PolygonList.
In the copy constructor of my class PolygonList, I want to fully duplicate the polygons which are stored, so that each PolygonList classes have their own polygon list.

class PolygonList
{
public:
...
std::list< Polygon*> m_PolygonList;
...
};

The problem is that the Polygon class is a base class :

class Polygon
{
...
};

class Rectangle : public Polygon
{
...
};

class Triangle : public Polygon
{
...
};

etc...

In the copy constructor of the class PolygonList, how can I make sure to instanciate a new object of the good derived class, as I only have pointers on the base class and don't know (and don't want to know) about which dervied class of Polygon exists ?

I hope I made myself clear and that you'll be able to help me !
Thanks !
Jerome
GeneralRe: duplicating derived classes Pin
Nemanja Trifunovic29-Apr-04 5:42
Nemanja Trifunovic29-Apr-04 5:42 
GeneralString Field Pin
Roger H. Art29-Apr-04 4:45
sussRoger H. Art29-Apr-04 4:45 
GeneralRe: String Field Pin
David Crow29-Apr-04 4:52
David Crow29-Apr-04 4:52 
GeneralRe: String Field Pin
Roger H Art29-Apr-04 5:16
sussRoger H Art29-Apr-04 5:16 
GeneralRe: String Field Pin
David Crow29-Apr-04 5:20
David Crow29-Apr-04 5:20 
GeneralCHtmlView resource download Pin
Jason Carter29-Apr-04 4:33
Jason Carter29-Apr-04 4:33 
GeneralCreateNamedPipe and CreateFile on Win98 Pin
Ceri29-Apr-04 3:40
Ceri29-Apr-04 3:40 
GeneralXML library for Visual Studio 6.0 Pin
pankajdaga29-Apr-04 3:26
pankajdaga29-Apr-04 3:26 
GeneralRe: XML library for Visual Studio 6.0 Pin
Anonymous29-Apr-04 6:39
Anonymous29-Apr-04 6:39 
GeneralRe: XML library for Visual Studio 6.0 Pin
pankajdaga29-Apr-04 6:49
pankajdaga29-Apr-04 6:49 
GeneralRe: XML library for Visual Studio 6.0 Pin
Ravi Bhavnani29-Apr-04 10:28
professionalRavi Bhavnani29-Apr-04 10:28 
GeneralRe: XML library for Visual Studio 6.0 Pin
pankajdaga29-Apr-04 11:40
pankajdaga29-Apr-04 11:40 
GeneralTreelist - right click selecting item Pin
Anonymous29-Apr-04 3:02
Anonymous29-Apr-04 3:02 
GeneralRe: Treelist - right click selecting item Pin
Anonymous29-Apr-04 10:20
Anonymous29-Apr-04 10:20 
GeneralRe: Treelist - right click selecting item Pin
thowra29-Apr-04 23:12
thowra29-Apr-04 23:12 
GeneralExtract data from database Pin
dreamerzz29-Apr-04 2:47
dreamerzz29-Apr-04 2:47 
GeneralRe: Extract data from database Pin
David Crow29-Apr-04 3:51
David Crow29-Apr-04 3:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.