www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/03/11:06:39

From: dontmailme AT iname DOT com (Steamer)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: vectors of derived objects
Date: Sat, 03 Mar 2001 15:56:04 GMT
Organization: always disorganized
Lines: 16
Message-ID: <3aa11402.12416404@news.freeserve.net>
References: <3aa1079f DOT 55821769 AT news1 DOT on DOT sympatico DOT ca>
NNTP-Posting-Host: modem-49.clown-goby.dialup.pol.co.uk
X-Trace: news6.svr.pol.co.uk 983634965 28506 62.136.247.49 (3 Mar 2001 15:56:05 GMT)
NNTP-Posting-Date: 3 Mar 2001 15:56:05 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Martin Smith wrote:

> The vector<class T> template apparently casts all elements in the
> vector as base objects in the situation where class T has classes
> derived from it.  
> 
> I would like to ba able to have the vector elements be able to use
> virtual function calls, so I guess the question is whether there is
> another template other than vector that I don't know about.

This is a question about C++, not DJGPP, so you would have been
better asking on comp.lang.c++.

But the answer is easy: you should use vector<base*> rather than
a vector<base>.  (You can use smart pointers instead of real
pointers if it makes it any easier.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019