|
From: Adam J. <aj...@i-...> - 2007-08-17 18:08:40
|
>>You wrote:
>>Can anyone tell me how to create objects (of a particular class) without
>>hard coding them? I want the program to prompt me to input a string of
>>characters then make an object of that name. I have thought of using cin
>>but I am still unsuccessful. Thanks for your time.
Class names can't be a parameter. Classes are created when the socurce code
is built. The compiler needs to know the name of the class. You can't use a
variable name as a class.
class foobar {
.......
....
}
foobar can't be a variable. It has to be a name. You also can't create
foobar and then assign it to some unknown vairable until runtime. Classes
and objects all have to be defined in the source code. The syntax to create
a new object of some type is typename pointer_name = new typename. No
variables allowed.
If I am wrong on this I would should like to see some working code.......but
I don't think I am. :)
-Adam Jones
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Tan,
Clarencio
Sent: Friday, August 17, 2007 3:59 AM
To: dev...@li...
Subject: [Dev-C++] Creating objects
Hi Guys,
Can anyone tell me how to create objects (of a particular class) without
hard coding them? I want the program to prompt me to input a string of
characters then make an object of that name. I have thought of using cin
but I am still unsuccessful. Thanks for your time.
Regards to all!
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
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
|