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

Discussion in 'C++' started by babakandme@yahoo.com, Dec 13, 2007.

  1. Guest

    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.
     
    , Dec 13, 2007
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > 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.

    --
    Ian Collins.
     
    Ian Collins, Dec 13, 2007
    #2
    1. Advertising

  3. Guest

    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...
     
    , Dec 13, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danno
    Replies:
    2
    Views:
    1,098
    Danno
    Apr 26, 2006
  2. David Stockwell
    Replies:
    2
    Views:
    554
    Grant Edwards
    Jun 8, 2004
  3. ashu
    Replies:
    7
    Views:
    327
    David Resnick
    Jan 26, 2006
  4. tenxian
    Replies:
    3
    Views:
    304
    RedGrittyBrick
    Apr 29, 2008
  5. Eric Danstron

    Are there ANY good forums out there anymore???

    Eric Danstron, Sep 21, 2005, in forum: ASP General
    Replies:
    1
    Views:
    156
    Immediacy
    Sep 22, 2005
Loading...

Share This Page