RE: [Dev-C++] Help with creating objects dynamically
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Somanathan K. <som...@wi...> - 2003-07-21 11:07:18
|
This is a strange requirement. Name of the object is normally irrelevant = compared to its definition. Do you mind in sharing your requirement? -----Original Message----- From: OROSZI Bal=E1zs [mailto:or...@vp...]=20 Sent: Monday, July 21, 2003 4:26 PM To: dev...@li... Subject: Re: [Dev-C++] Help with creating objects dynamically Satish Medepalli wrote: > I have the following requirement while creating objects.. I will = 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 > stored in a character array at run time.. say i have the following > 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 = the > object using that particular name at run time.. i.e.,=20 > Student JOHN; =20 >=20 > in a nutshell i want to give the name of the objects to be created = at > run time. IS THIS POSSIBLE?? IF SO CAN ANYONE HELP ME WITH THIS?? Nope. As far as I know, this is not possible in C++. I know, that Perl=20 can do it, but if you EVER programmed in Perl, you know how different it = is. So I don't think it ca nbe done. A solution to your problem might be to give a "name" member to your=20 class, then at object creation, the constructor takes it as parameter,=20 and copies it into the name member. -- Greetings, Bal=E1zs ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |