Is there any """Anti Stringizing operator #"""

B

babakandme

Hi everybody:D


I've a string that contains the name of a class.

Some members told that I can use """Stringizing Operator (#)""", but
the problem is here, that I have the string, & I want something vice-
versa.
As we know with """Stringizing Operator (#)""", we can get the stirng
name of a class or ... str <--- #ClassA

But I want to instantiate a class that I have just it's name as a
string.
ClassA * clsA = new ??? <--- Str ???

How can I do it?
I don't want to use """HardCoding""".

Thanks.
 
I

Ian Collins

Hi everybody:D


I've a string that contains the name of a class.

Some members told that I can use """Stringizing Operator (#)""", but
the problem is here, that I have the string, & I want something vice-
versa.
As we know with """Stringizing Operator (#)""", we can get the stirng
name of a class or ... str <--- #ClassA

But I want to instantiate a class that I have just it's name as a
string.
ClassA * clsA = new ??? <--- Str ???

How can I do it?
I don't want to use """HardCoding""".
Why all the triple quotes?

It sounds like you are looking for the factory pattern.

You can't instantiate a class by name dynamically in C++ like you can in
scripting languages.
 
B

babakandme

Yeah my Man:>
thanks...

Actually first I didn't want to use any HardCoding...
But now I see, here the FactoryMethod Pattern works...


Why all the triple quotes?
They are just for more attention, & make the issue more visible:>

Once again, thank you in advance...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top