home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ukma!gatech!darwin.sura.net!haven.umd.edu!news.umbc.edu!gmuvax2!twallace
- From: twallace@gmuvax2.gmu.edu (Todd Wallace)
- Subject: Re: name of object
- Message-ID: <1993Jan28.173602.5232@gmuvax2.gmu.edu>
- Organization: George Mason University, Fairfax, Va.
- References: <g++FAQ_01_15_1993_texi@ohm.berkeley.edu> <g++FAQ_01_15_1993_plain@ohm.berkeley.edu>
- Date: Thu, 28 Jan 1993 17:36:02 GMT
- Lines: 36
-
- Here is an odd question for the OOP gurus:
- Is there a way for an object to know its own name?
-
- For instance, let's say we declare the following class:
- class Lemon {
- public:
- //some stuff
- };
-
- void main(void)
- {
- Lemon A,B,C;
-
- A.tell_me_your_name;
- B.tell_me_your_name;
- C.tell_me_your_name;
- }
-
- and I would like the output to be:
- A
- B
- C
-
- Therefore, I have to declare a member function for Lemon that
- can look up its own name.
-
- Can it be done? It would help a lot with debugging.
-
-
- ----------------------------------------------------------------
- | Todd Wallace | "A pessimist is surprised |
- | twallace@gmuvax2.gmu.edu | as often as an optimist, |
- | | but always pleasantly." |
- | | - Robert Heinlein |
- ----------------------------------------------------------------
-
-