Topic: typename" to typename
Author: David R Tribble <dtribble@technologist.com>
Date: 1999/05/07 Raw View
Seng Joo wrote:
> If I have a char* containing "ABC", and I have a class named ABC as
> well, how can I associate the two during run time?
It's not clear what you are asking. You might consider re-posting
the question to news:comp.lang.c++.moderated. (I've redirected
follow-ups there.)
But I'll take a guess at what you mean:
// abc.h
class ABC
{
public:
static const char *const name;
...
};
// abc.cpp
#include "abc.h"
const char *const ABC::name = "ABC";
-- David R. Tribble, dtribble@technologist.com --
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Seng Joo" <thiosg@pacific.net.sg>
Date: 1999/05/04 Raw View
Hi all!
If I have a char* containing "ABC", and I have a class named ABC as well,
how
can I associate the two during run time?
TIA!
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Edward Diener <eddielee@abraxis.com>
Date: 1999/05/04 Raw View
What do you mean by "associate the two during run time" ?
Seng Joo wrote:
> Hi all!
>
> If I have a char* containing "ABC", and I have a class named ABC as well,
> how
> can I associate the two during run time?
>
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 1999/05/04 Raw View
Seng Joo wrote:
>
> Hi all!
>
> If I have a char* containing "ABC", and I have a class named ABC as well,
> how
> can I associate the two during run time?
Could you give an example of what you want to do with the association?
I've thought of two or three different ways to do it, but the "best" way
is likely to be more complicated than you really need.
Alternatively, it's possible that what you want is impossible.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Philip Koester" <kozmik@okay.net>
Date: 1999/05/05 Raw View
>If I have a char* containing "ABC", and I have a class named ABC as well,
>how
>can I associate the two during run time?
This is a somewhat sick idea and is not encouraged by the language, I guess
you're on the wrong track there. But as it turns out, there is a way to do
it. Firstly, look what particular name your particular compiler generates
for that class:
cout << typeid(ABC).name() << endl;
The next step could be that you register all of your ABC objects in a global
map or hash table or whatever ... *shudder*
Philip
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]