473,566 Members | 2,770 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi everybody:D
I've a string that contains the name of a class.

Some members told that I can use """Stringiz ing Operator (#)""", but
the problem is here, that I have the string, & I want something vice-
versa.
As we know with """Stringiz ing 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 '07 #1
2 2006
ba********@yaho o.com wrote:
Hi everybody:D
I've a string that contains the name of a class.

Some members told that I can use """Stringiz ing Operator (#)""", but
the problem is here, that I have the string, & I want something vice-
versa.
As we know with """Stringiz ing 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.
Dec 13 '07 #2
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 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
6412
by: Pmb | last post by:
I've been working on creating a Complex class for my own learning purpose (learn through doing etc.). I'm once again puzzled about something. I can't figure out how to overload the assignment operator. Here's what I'm trying to do. I've defined class Complex as class Complex { friend ostream &operator<<( ostream &, Complex & ); public:...
8
1512
by: John Pass | last post by:
When displaying output in a MessageBox, using a variable Output as string, the &= operator is used instead of the = operator. In which cases is the &= operator used?
9
2186
by: Emanuele Aina | last post by:
I have some code which does a lot of "in" on lists containing objects with no __eq__ defined. It all goes fast until I add the __lt__() method: then I have a slowdown comparable to the one I get using the overridden __eq__, while the __lt__ method is never called. Someone can explain me why?
8
1874
by: av | last post by:
i have my little string class, now i want do define something like this but for doing it i have to write sstream& operator+(char* a, char* b){} but compiler say something like "operator+(char*, char*) must be a member function or have a parameter of class type"
2
2753
by: John Goche | last post by:
Hello, Could anyone please provide with some information on the C++ overloaded cast operator and in which circumstances this might be useful? I have consulted several references but found no information on the uses of this operator. Thanks, JG
8
1778
by: Prateek | last post by:
Hey... Can anybody tell me why "<<" operator is used behind cout? Like: cout<<"Welcome"; My one friend told me that it "shifts the bits"...But it's not very clear to me...Can anybody tell?
5
2578
by: Gianni Mariani | last post by:
I'm hoping someone can tell me why using member address of works and why using the dot operator does not in the code below. The code below uses the template function resolution mechanism to determine wether a class contains a member. My understanding is that if a template function has an error during resolution of the function types, it is...
14
2791
by: Jess | last post by:
Hi, I read about operator overloading and have a question regarding "operator->()". If I have two classes like this: struct A{ void f(); }; struct B{
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.