Using a variable to reference an object.

Hello, I am currently working on streamlining my code and was wondering if it is possible to use a variable to reference a specific object.
For Example
Say I named a object 1 and had a int variable named b that stored 1 could i say
b.Set(true) and have the same result as 1.Set(True)
If it cannot be done this way is there another way to get the same result. The key to what I want is to have a numeric value that relates to a specific object.

Thanks for any help in advance. :)
I don't understand what you mean? Do you mean references (int &b = a; makes a and b the same object)?
Ill try to explain again. Basically I want to be able to use a INT variable to select a specific object in order to execute a command.
If INT B =1 and I say B.Set(true) I want it to run the Set(True) command for the object named 1 this would normally be typed as 1.Set(true);

note: Set(true) is just from my program not a direct C++ command.
You need to make an array.
can u be more specific
1
2
3
4
5
6
7
8
9
10
class Thing {
	//blah blah blah
	set(bool b){/*blah*/}
}

int main(){
	Thing thing[10];
	int b=1;
	thing[b].set(true);
}
k thanks
Exactly why aren't you using a pointer?
If you absolutely want an int, you can use a map, a vector, a function...
Topic archived. No new replies allowed.