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], Tyler Littlefield <ty...@...> 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?
> >
> >
>