Click here to Skip to main content
15,897,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to instance a class which name is in a string? Pin
ThatsAlok9-Feb-10 0:08
ThatsAlok9-Feb-10 0:08 
GeneralRe: How to instance a class which name is in a string? Pin
Cedric Moonen9-Feb-10 1:04
Cedric Moonen9-Feb-10 1:04 
GeneralRe: How to instance a class which name is in a string? Pin
Moak8-Feb-10 5:23
Moak8-Feb-10 5:23 
GeneralRe: How to instance a class which name is in a string? Pin
ThatsAlok9-Feb-10 0:09
ThatsAlok9-Feb-10 0:09 
AnswerRe: How to instance a class which name is in a string? Pin
«_Superman_»8-Feb-10 5:30
professional«_Superman_»8-Feb-10 5:30 
GeneralRe: How to instance a class which name is in a string? Pin
ThatsAlok9-Feb-10 0:14
ThatsAlok9-Feb-10 0:14 
AnswerRe: How to instance a class which name is in a string? Pin
ThatsAlok9-Feb-10 0:05
ThatsAlok9-Feb-10 0:05 
GeneralRe: How to instance a class which name is in a string? Pin
Cedric Moonen9-Feb-10 1:01
Cedric Moonen9-Feb-10 1:01 
This has nothing to do with "hacking". There are some cases where this is extremely useful (it depends a lot on the context of course). And your point about polymorphism has nothing to do with the question. Creating a specific instance of a class using an Id (a name for instance) using a factory pattern uses polymorphism anyway.

Here's a concrete example in which this could be useful. Suppose you have a program that is able to execute a list of operations. The user is able to create an XML file containing the information about the different operations to execute. What you would typically do is have a different nodes in your XML file (one for each operation you want to execute). And for each of these nodes, you can have parameters which are specific to the operation you want to execute. One property of the node is of course the name of the operation to execute. This way, when loading the file you get the name of your operation, delegate the creation of the operation to the factory and pass the parameters to the operation object so that it can "configure" itself from the xml information. Once your object is constructed, you can store it in a list along other operations to be executed. Of course, all the specific operation classes inherit from the same base class (which provide virtual functions like run, loadPropertiesFromXML, ...).

This is of course one simple example but there are a lot of cases where this becomes useful.
Cédric Moonen
Software developer

Charting control [v3.0]
OpenGL game tutorial in C++

QuestionRegConnectRegistry and RegOpenKey return Access is Denied. Pin
Le@rner8-Feb-10 1:57
Le@rner8-Feb-10 1:57 
Questionhow to create a button in cview class? Pin
Paulraj G8-Feb-10 1:16
Paulraj G8-Feb-10 1:16 
AnswerRe: how to create a button in cview class? Pin
Code-o-mat8-Feb-10 1:36
Code-o-mat8-Feb-10 1:36 
GeneralRe: how to create a button in cview class? Pin
Paulraj G8-Feb-10 1:39
Paulraj G8-Feb-10 1:39 
AnswerRe: how to create a button in cview class? [modified] Pin
transoft8-Feb-10 3:35
transoft8-Feb-10 3:35 
AnswerRe: how to create a button in cview class? Pin
sthalasayanam8-Feb-10 4:43
sthalasayanam8-Feb-10 4:43 
AnswerRe: how to create a button in cview class? Pin
KingsGambit8-Feb-10 8:49
KingsGambit8-Feb-10 8:49 
QuestionGrid with check boxes in coloum headers Pin
arun_pk7-Feb-10 23:20
arun_pk7-Feb-10 23:20 
AnswerRe: Grid with check boxes in coloum headers Pin
«_Superman_»8-Feb-10 5:41
professional«_Superman_»8-Feb-10 5:41 
QuestionCString to double conversion. Pin
Member 43997717-Feb-10 22:50
Member 43997717-Feb-10 22:50 
AnswerRe: CString to double conversion. Pin
Cedric Moonen7-Feb-10 23:01
Cedric Moonen7-Feb-10 23:01 
AnswerRe: CString to double conversion. Pin
transoft8-Feb-10 3:43
transoft8-Feb-10 3:43 
GeneralRe: CString to double conversion. Pin
ThatsAlok9-Feb-10 0:15
ThatsAlok9-Feb-10 0:15 
AnswerRe: CString to double conversion. Pin
«_Superman_»8-Feb-10 5:55
professional«_Superman_»8-Feb-10 5:55 
QuestionHow can i retrieve phone number using MS-COMM OCX Pin
emmmatty17-Feb-10 22:48
emmmatty17-Feb-10 22:48 
AnswerRe: How can i retrieve phone number using MS-COMM OCX Pin
Roger Stoltz8-Feb-10 4:49
Roger Stoltz8-Feb-10 4:49 
QuestionHWND_TOP to make a dialog topmost??? Pin
Arrin7-Feb-10 21:21
Arrin7-Feb-10 21:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.