Click here to Skip to main content
15,890,609 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Registry and VISTA Pin
Bram van Kampen12-Mar-08 15:37
Bram van Kampen12-Mar-08 15:37 
GeneralRe: Registry and VISTA Pin
Mark Salsbery29-Feb-08 7:49
Mark Salsbery29-Feb-08 7:49 
GeneralRe: Registry and VISTA Pin
Bram van Kampen29-Feb-08 14:25
Bram van Kampen29-Feb-08 14:25 
GeneralRe: Registry and VISTA Pin
Bram van Kampen12-Mar-08 15:35
Bram van Kampen12-Mar-08 15:35 
GeneralRe: Registry and VISTA Solved Pin
Bram van Kampen13-Mar-08 11:34
Bram van Kampen13-Mar-08 11:34 
GeneralRe: Registry and VISTA Solved Pin
Mark Salsbery13-Mar-08 11:42
Mark Salsbery13-Mar-08 11:42 
Generalspecifying object type at compile time Pin
act_x28-Feb-08 12:50
act_x28-Feb-08 12:50 
GeneralRe: specifying object type at compile time Pin
Chris Losinger28-Feb-08 15:54
professionalChris Losinger28-Feb-08 15:54 
i'd just do it with a switch

ProcessObject( int objCode  )
{
   A* a = NULL;
   switch (objCode)
   {
       case 0: 
         a = new whatever0;
         break;
       case 1: 
         a = new whatever1;
         break;
       etc..
   }
   a->Foo();
}


otherwise, maybe you could add static Create methods to your object types, and put refs to those in your array (off the top of my head):

class whatever0 : public A
{
  static public whatever0 * Create()
  {
     return new whatever0();
  }
  ...
};
class whatever1 : public A
{
  static public whatever1 * Create()
  {
     return new whatever1();
  }
  ...
};

...

OBJ_TYPE objTable[] = 
{
  {0, whatever0::Create},
  {1, whatever1::Create},
};

... where OBJ_TYPE is a struct with an int and a function pointer that returns an A* 


you'd need the static Create functions because you can't do function pointers to non-static member classes.


GeneralDialog Box Refresh Pin
RomTibi28-Feb-08 5:50
RomTibi28-Feb-08 5:50 
GeneralRe: Dialog Box Refresh Pin
led mike28-Feb-08 5:58
led mike28-Feb-08 5:58 
GeneralRe: Dialog Box Refresh Pin
RomTibi29-Feb-08 6:20
RomTibi29-Feb-08 6:20 
GeneralRe: Dialog Box Refresh Pin
led mike29-Feb-08 6:32
led mike29-Feb-08 6:32 
GeneralRe: Dialog Box Refresh Pin
RomTibi29-Feb-08 7:35
RomTibi29-Feb-08 7:35 
GeneralRe: Dialog Box Refresh Pin
RomTibi1-Mar-08 22:23
RomTibi1-Mar-08 22:23 
GeneralRe: Dialog Box Refresh Pin
led mike2-Mar-08 14:54
led mike2-Mar-08 14:54 
GeneralRe: Dialog Box Refresh Pin
RomTibi4-Mar-08 5:04
RomTibi4-Mar-08 5:04 
GeneralRe: Dialog Box Refresh Pin
Michael Schubert28-Feb-08 7:03
Michael Schubert28-Feb-08 7:03 
GeneralRe: Dialog Box Refresh Pin
RomTibi29-Feb-08 6:22
RomTibi29-Feb-08 6:22 
GeneralRe: Dialog Box Refresh Pin
Bram van Kampen28-Feb-08 12:57
Bram van Kampen28-Feb-08 12:57 
GeneralRe: Dialog Box Refresh Pin
RomTibi29-Feb-08 6:22
RomTibi29-Feb-08 6:22 
GeneralRe: Dialog Box Refresh Pin
Michael Dunn28-Feb-08 13:08
sitebuilderMichael Dunn28-Feb-08 13:08 
GeneralRe: Dialog Box Refresh Pin
RomTibi29-Feb-08 6:23
RomTibi29-Feb-08 6:23 
GeneralGetting a base word from an extended word. [Solved] Pin
Kiss The Kipper28-Feb-08 5:49
Kiss The Kipper28-Feb-08 5:49 
GeneralRe: Getting a base word from an extended word. Pin
led mike28-Feb-08 6:39
led mike28-Feb-08 6:39 
GeneralRe: Getting a base word from an extended word. Pin
Kiss The Kipper28-Feb-08 10:22
Kiss The Kipper28-Feb-08 10:22 

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.