RE: [Dev-C++] Help with creating objects dynamically
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Marc H. <ma...@e-...> - 2003-07-22 04:35:58
|
Hi Sateesh, I think what you're looking for is the STL std::map which serves as a = kind of associative array. There are other guys on this list more educated in = the ways of STL than I. I'm sure they will help you out if you have = problems.=20 __________________________________ Marc Heiligers -----Original Message----- Hello Marc, Thank you for your reply. There is no real necessity for me to do so.. = I can make it work using a hash table or some kind of a mapping function.. = I just thought that if it was possible in the way I earlier asked, I could save some execution time as there will not be much need for searching operation.. As i got almost every feedback saying that this is not possible, I = think I will stick to a hash table solution. Thank you for all your help with this. -Sateesh Medepalli --- Marc Heiligers <ma...@e-...> wrote: > I can see absolutely no requirement to do this at all. In addition=20 > (and to answer the question) I can see absolutely no way of doing it=20 > either. Scripting languages that have some kind of eval statement=20 > could do this, but > again, I can see no requirement for it (although I have used a similar > mechanism in a JScript ASP project to create objects of a particular > name, > but never dependant on data within the object itself).=20 >=20 > Maybe if you enlighten us on why you would want to do this, we could=20 > help you find a solution. >=20 > __________________________________ > Marc Heiligers >=20 > -----Original Message----- >=20 > I have the following requirement while creating objects.. I will=20 > try to explain it using a small example.. >=20 > Suppose I have a class Student defined and I want to create objects = > of type Student inside the main function.. >=20 > And say, the actual name with which i want to create the obect is=20 > stored in a character array at run time.. say i have the following=20 > statement char NAME[]=3DgetName(); > and the above function is returning the name "JOHN" at run time. >=20 > Now i want to get the name out of the character array and create=20 > the object using that particular name at run time.. i.e., Student=20 > JOHN; >=20 > in a nutshell i want to give the name of the objects to be created=20 > at run time. IS THIS POSSIBLE?? IF SO CAN ANYONE HELP ME WITH THIS?? >=20 > Thank You in advance. > -Sateesh Medepalli |