List of void * type



 DEVELOP > c-Plus-Plus > List of void * type

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Stub"
Date: 09 Nov 2003 03:37:33 PM
Object: List of void * type
If building a list of elements of void * type, this way different pointer
types of objects can be put in the list. When you pop data from the list,
can RTTI or any other method be used to determined what pointer type of
object is returned the list?
.

User: "Cy Edmunds"

Title: Re: List of void * type 09 Nov 2003 05:06:12 PM
"Stub" <stub@asof.com> wrote in message
news:xsyrb.40697$Ec1.3066693@bgtnsc05-news.ops.worldnet.att.net...

If building a list of elements of void * type, this way different pointer
types of objects can be put in the list. When you pop data from the list,
can RTTI or any other method be used to determined what pointer type of
object is returned the list?


Use of void* in any other context than very low level hardware or operating
system manipulations is almost always a mistake in C++. Build a list of
reference counted smart pointers to a polymorphic base class and you can
have what you wanted without disabling or even compromising the type system.
And then avoid RTTI in favor of virtual functions.
--
Cy
http://home.rochester.rr.com/cyhome/
.

User: "Rolf Magnus"

Title: Re: List of void * type 09 Nov 2003 04:50:20 PM
Stub wrote:

If building a list of elements of void * type, this way different
pointer types of objects can be put in the list. When you pop data
from the list, can RTTI or any other method be used to determined what
pointer type of object is returned the list?

No. If you want different types, use a pointer to a polymorphic base
class that points to objects of classes derived from that base class.
RTTI will also only work within such a class hierarchy.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER