   Is There a way.....
  Hi Guys,Hop your all good from the weekend and have a good week ahead!Now then ,assuming I have a class cObject,and I want to create several hundred instances of these.And the name of each has to be independant, not just the memory addresses.And I want each one to be for example.cObject Instance1;cObject Instance2;etc etc..Is there way i can decare them within a for loop using a string variable as there name? For examplechar strName[15] = "Instance";char strNumber[4];For(int i = 0; i < MAX;i++){sprintf(strNumber,"%d",i);strcat(strName,strNumber);cObject strName; // What to do here?! This obviously fails!}Thanks for advice.Pete 
  No. ;  Throw them into an associative array with a string key. Then you can retrieve and invoke each object using the name. One such associative array construct would be std::map.As for the method you considered, that''s not possible in C++. ;  Oluseyi is right.But why do you need to do this? There might be a better way. ;  You could do some funky Macro trick to do it, but if you were gonna do that, you''d want to use the same trick to access the variables, and would (I assume) be done in some loop in any case you needed to access them... That being said, using a map is your best bet, as the guy above stated... ;  Why do the variable names have to be unique?  I can''t fathom how this would be useful to you in a program.Why not just declare these objects in an array:cObject Instance[100];;  This is why God created dynamic allocation (new/delete).Also, calling strcat() on the name will keep appending numbers, so the second one will be called Instance01, the third one Instance012, ...Here''s how it could be done:cObject * gInstances[ 100 ];for( int ix = 0; ix < 100; ++ix ) {  char name[ 30 ];  sprintf( name, "Instance%d", ix );  gInstances[ ix ] = new cObject( name );}  If you need to reference "Instance10" then just write that as (*Instance[10]).