You are not logged in.
good evening everyone,
i have a question ...
i have written a class with "class" ...
then i have a string with name "give_in_text" ...
i want to create a class-object with a name/ID , that is the contain of the string "give_in_text" ... and that should variating, because "give_in_text" is a string with text written by user with "cin" ...
and then i write a code and everytime, when the inserted text of the string "give_in_text" is in my code, then i want to use the object of the class...
i think, that c++ translates names of classes, strings and variables to a hex-address in the RAM ... i would find it better with the hex-address instead of the text, because the programme runs faster then ...
i would use that for many things like in methods ...
cin >> give_in_text ; // here the user writes text ...
...
class_name give_in_text ; // here a class-object in the class "class_name" should be created and the object should have the name of the text, that was written in cin above by user ...give_in_text.method(...) ; // here the class-object, that was named by the user with cin-text, should be used with a method of the public-zone of the class ...
is that possible in c++ ?
Last edited by lo7777799 (2025-06-29 19:48:00)
Offline
is that possible in c++ ?
No. C++ is statically-typed language. You can't create arbitrary data types at runtime.
What problem are you trying to solve by this?
i think, that c++ translates names of classes, strings and variables to a hex-address...
Class is a type, not an object. Types have no addresses. Of course, compiler operates with symbolic type names during compilation and keeps those names at some addresses at compile time. Those addresses make no any sense outside of compiler process.
For type identification at runtime see typeid operator and std::type_info.
Offline
First off all: https://deepl.com/ - I don't want to complain, but you've clearly no idea what you're talking about and your efforts to describe that are borderline unintelligible.
Then, for context: https://bbs.archlinux.org/viewtopic.php?id=306169
You're trying to brick together some program based on some ill-conceived ideas.
What you can do is read the input, compare the string to some pattern and decide what to do based on that.
You cannot generate random functions or variables at runtime out of thin air, you'd map strings to instances, eg. with a hash table.
Even if you could: how would the code then address them prima face? Nothing of your human readable variable name remains once you strip the binary of debug symbols.
i would find it better with the hex-address instead of the text, because the programme runs faster then ...
This is complete nonsense. You're dealing w/ user input - everything the user does is incredibly SLOOOOOOOOOOOOOW from the perspective of the CPU.
I can type 200 words per minute, but the CPU is mostly bored, waiting for my lame human fingers to finally hit the key.
I suggest you start to lay out your end goal here: what do you actually want to achieve in the end. Don't try to employ code lingo, just explain in casual terms what you want to do.
Last edited by seth (2025-06-29 20:04:01)
Offline