Oh brother! I left of the (). Thanks everyone for all the help tonight. It is working!...almost.
Now my program does not exit cleanly. Using glut it opens a console window and an openGL window. If I close the console it seems to shut down (can't garantee no memory leaks), but if I close the glut window the console does not close as it does in a pure c program. Thanks again for all the help. Best regards, Jimmy J. Johnson --- In [email protected], Thangaraj <thangaraj...@...> wrote: > > Jimmy, > > Yes, you are correct. This kind of feature is supported by C++ and its > generally called as RTTI (Run Time Type Idendification). > There is a small syntax problem with your code. The typeid() returns an > object of type type_info and it has a member function name() to get the > object name string. > Here is the corrected code > > myClass::doSomething() { > cout << typeid(this).name(); > } > > hope this works for you. good luck. > > regards, > Thanga > > > On Mon, Jan 25, 2010 at 8:43 AM, Jimmy Johnson <boxer...@...> wrote: > > > > > > > There is a feature/object/intety [I'm not sure what the c-terminology is] > > called `typeid' in <typeinfo> that takes an object as argument with a > > feature called name, as in > > > > cout << typeid(anObject).name() > > > > It "Returns a null-terminated character sequence with a human-readable name > > for the type." > > > > My problem seems to be with the self reference usage in > > > > myClass::doSomething() { > > cout << typeid(this).name; > > } > > > > What am I missing? > > > > > > --- In [email protected] <c-prog%40yahoogroups.com>, Tyler > > Littlefield <tyler@> wrote: > > > > > > hello, > > > c++ doesn't store the name of the class in the binary, you'll have to > > store that yourself if you want it. > > > > > > Thanks, > > > Tyler Littlefield > > > http://tds-solutions.net > > > Twitter: sorressean > > > > > > On Jan 24, 2010, at 7:35 PM, Jimmy Johnson wrote: > > > > > > > Thanks to Tyler, Peter, Furgan for your quick help. Wow! > > > > > > > > I have another. I am trying to simply print a statement containing the > > name of the generating class (or type of the object) when the constructor is > > called. Like... > > > > > > > > myClass::myClass() { > > > > cout << "Debug: call constructor for "; > > > > cout << typeid(this).name << "\n"; > > > > }; > > > > > > > > The compiler complains with > > > > error C3867: 'type_info::name': function call missing argument list; > > use '&type_info::name' to create a pointer to member > > > > > > > > So I change the above to include & in front of typeid and get: > > > > error C2276: '&' : illegal operation on bound member function > > expression > > > > > > > > So, what's with that? > > > > > > > > > > > > > > > > > > > > [Non-text portions of this message have been removed] >
