posted 20 years ago
One question about creating objects.
say i have a simple object.
Foo(int id)
i can create seperate objects by doing
Foo a = new Foo(1);
Foo b = new Foo(2);
but as each object can be referenced a seperate id number, by doing
for(int i=0;i<10;i++)
{
Foo A = new Foo(i);
}
1) Do i get 10 seperate Foo objects named A?
2)in addition, if the answer to part 1 of my question is Yes, then how to i
find out about say object 2 of Foo A ?
ie usually i can do A.doSomething(); B.doSomething();
but if i create my objects using the loop, how do i want object 2 to do a method? A2.doSomething() //???
I am thinking the solution is storing them in list/array, and referencing them using the list/arrary. Am i right?
but the question remains, is Foo A = new Foo(1); and Foo A = new Foo(2);
considered seperate objects?
thanks for the help!