Discussion Locked

Access to C++ pointer type

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
A recent C++ article compared C and C++ pointers, stating that C++ pointers have attributes such as 'type'. Is there a way to find the type of a pointer selected from an array of pointers, and use that pointer to guide the next step in the program?

3 replies

by asivakumar

The c++ pointers type can be identified by the RTTI Information ,their is system function called typeid(specify the type u want to check).name() which will return you type of data u r using ..

sivakumar a

by macgrrl

Two of the fundamental tenets of Object Oriented Programming are inheritance and polymorphism. Careful design of the class hierarchy with virtual methods will often obviate the need for type determination at runtime - which comes with a performance hit.

by jp

if yr problem space allows pure object oriented techniques, why use c++ at all.

you cld use java or python, or even lisp, & it wld be a lot mor fun.

for me, part of the fun of c/c++ is that if i want to i can write my own java, python or even lisp objects, outside of the restrictions of those languages. yippee.

& if that means not being object oriented, & casting void pointers into mission critical intelligent agents, i will do it w/out apologies.

heyup?

This discussion is closed to new replies.