help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining the name of the C++ class from the pointer


From: Paul Pluzhnikov
Subject: Re: Obtaining the name of the C++ class from the pointer
Date: Mon, 01 May 2006 17:12:21 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Andreas Schallenberg <no_reply@yahoo.com> writes:

> X * ptr;
> cout << "type is " << typeid(*ptr).name() << endl;

Just a word of caution: if X doesn't have virtual functions,
typeid(*ptr) will "answer" X even if "ptr" points to a subclass of X.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]