Skip to main content
GameDev.net gamedev.net
🔒 Locked

Does void* kill RTTI?(C++)

Started by BarnyardMessiah Nov 18, 2003 at 11:33 PM 4 replies 550+ views
Original Post
BarnyardMessiah
BarnyardMessiah
To limit debugging for my upcomming "really stupid game"(tm), I decided to use my old linked list class. It''s odd, but it''s bug free. So anyways, it uses void pointers. If I write a rapper around the return function so it casts the void* to the base class type and return that, can I still use RTTI to dynamic_cast it later for the right overloaded funtion to work?
Sneftel
Sneftel
yes, you can (not required by the standard, but would work on any half-decent compiler). But don''t. Instead, rewrite your class to use templates. It''s surprisingly little work, and it''s worth it.


"Sneftel is correct, if rather vulgar." --Flarelocke
cilcoder
cilcoder
hrmm. If I understand you correctly, it should work. You could always create your own linked list template for type safety but I guess you don''t want to do that to make the process go quicker. Although I''ve never really used the STL, I''m sure STL has something you can use.
Clash
Clash
As clipcoder suggested the STL has a doubly linked list templated class you can use. It''s in the header file "list" and is called std::list. As long as you are using an optimizing compiler, it will run as fast, if not faster, than any homebrew linked list. Not to mention, it''s rock solid.

Hope that helps.
Jason Citron- Programmer, Stormfront Studios- www.stormfront.com
BarnyardMessiah
BarnyardMessiah
thanks for the responce.

I''ll see if retypeing it will work. And for future refrence, STL is cross platform right?

Oh, and we hardly know eachother Clash, how can you say my code is slow? j/k
BarnyardMessiah
BarnyardMessiah
actually what I should of posted was Polymorphism, and yeah, the void* does kill it.

Hard.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.