| | |
dynamic object names
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 158
Reputation:
Solved Threads: 3
I am trying to figure out for my physics simulator how to give my object name a variable or something, ill show an example and the compiler flags it an error but all i am trying to do is pass it the value not the variable
long atomID = 0;
atom atomID;
struct atom
{
short radius;
}
im just trying to get the object of atom to be called 0 so that i can reference all of my objects if lets say the simulator has 100 atoms operating in it at once. but doing it like this I want to be able to create all the atoms like this by just incrementing the atomID so i have a new variable name or something. does anyone have ideas for implementing an idea like this.
long atomID = 0;
atom atomID;
struct atom
{
short radius;
}
im just trying to get the object of atom to be called 0 so that i can reference all of my objects if lets say the simulator has 100 atoms operating in it at once. but doing it like this I want to be able to create all the atoms like this by just incrementing the atomID so i have a new variable name or something. does anyone have ideas for implementing an idea like this.
•
•
Join Date: Jun 2008
Posts: 158
Reputation:
Solved Threads: 3
can the name possibly be a number or something, it has to be something that I can increment by 1 or something before I make another atom object, and yes I have used pointers like once or twice but havent found too much use for them yet in my programming, maybe now is the time
so basically everytime I create an atom object its name has to be slightly different to differentiate between all the atoms created in the simulator.
so basically everytime I create an atom object its name has to be slightly different to differentiate between all the atoms created in the simulator.
•
•
Join Date: May 2008
Posts: 570
Reputation:
Solved Threads: 93
This sounds a lot like another recent thread where the developer 'needed' to name the variables based on user input.
The name that you use inside the source need not have anything to do with the name the user sees. It would be your responsibility as the developer to map the elements of the array or vector or whatever other data structure you think would best fit your needs to the names the user is using.
The name that you use inside the source need not have anything to do with the name the user sees. It would be your responsibility as the developer to map the elements of the array or vector or whatever other data structure you think would best fit your needs to the names the user is using.
Well, you have used a compiled, not interpretive language, so "basically everytime you create an atom object its name (and therefore all your program source text) has to be slightly different to differentiate between all the atoms created in the simulator". In other words, you must recompile, relink and reload all your program "everytime you create an atom object". It's cool! Do you find it funny? I do 
Think: no source program names at run-time! There are a sequence of machine instructions. What unexistence entities are you intending to change "everytime you create an atom"?

Think: no source program names at run-time! There are a sequence of machine instructions. What unexistence entities are you intending to change "everytime you create an atom"?
•
•
•
•
can the name possibly be a number or something, it has to be something that I can increment by 1 or something before I make another atom object, and yes I have used pointers like once or twice but havent found too much use for them yet in my programming, maybe now is the time![]()
so basically everytime I create an atom object its name has to be slightly different to differentiate between all the atoms created in the simulator.
The "names" which you see when you're writing your code are for your convenience only - when you send your program through the compiler, those names become non-existant, because your computer doesn't need them - it remembers objects by their 'index' (address) in your computer's memory instead.
¿umop apisdn upside down? ![]() |
Similar Threads
- Dynamic Multithreading help (C#)
- help with dynamic memory (C++)
- Object Oriented Programming (Computer Science)
- I need help (Viruses, Spyware and other Nasties)
- what is object oriented???? (IT Professionals' Lounge)
- another newbie with alot of redhat and apache server Q'S (Linux Servers and Apache)
- I can't remove about:blank (Viruses, Spyware and other Nasties)
- Another Trojan.Bookmarker.Gen (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: protected static members of a Class
- Next Thread: songa rating prog
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






