By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

List of void * type

P: n/a
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?
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Jul 19 '05 #2

P: n/a
"Stub" <st**@asof.com> wrote in message
news:xs*********************@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/
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.