   Generated code and naming variables
  This should be an easy question for most experienced programmers, but I have no idea how this would be done. I have an object (container_obj) that will create new objects (new_obj) that the first object will contain. When the container_obj creates a new object, I want it to be able to give the new_obj a name. So when the new_obj is declared, it is done so with the generated name.Is this possible? If not, what other options should I pursue aside from having a "string newObjName" variable?Thank you...   
  What language? Also, could you describe in a little more detail what you're wanting to do? (Or perhaps give an example...)   ;  If you are describing what I think you are describing...and if you are talking C++...If you want to associate some name X with some object Y try a std::map< std::string, new_obj_type >Objects in a map are associated with a key ( in this case a string ), and can be retrieved via map::find( key );So you can have mymap.insert( std::pair<std::string, new_obj_type> ( "foo1", new new_obj_type ) );std::map< std::string, new_obj_type >::iterator itr = mymap.find( "foo1" );if ( itr != mymap.end() ){itr->doSomething();}If you are talking about being able to write code like:container_obj.make_new( "bar" );bar.doSomething();that isn't possible. in c++.   ;  Yes I'm using C++, sorry.KulSeran, your second example is what I was talking about. So I guess I'll just stick to having a string name.Thanks all.   