Lets say i have this code:
My question is:Code:#include <iostream> using namespace std; class test { int a; public: test(int); int r_a(); }; int test::r_a() { return a; } test::test(int x) { a=x; } int main() { int y=0; char c; test b(y); y++; switch(c=cin.get()) { case '1': { test b(y); y++; } default: y++; break; } cout <<b.r_a(); }
is it possible to have more than 1 object with the same name??
and if yes, how do we distinguish them and call them individualy?? (how do u make them unique??)
If not then what happens when i press 1 and create another object with the same class and the same name??? is the current object replaced by that new one?? (for example the first object had y==0 and now as i created a new one that value is overwriten staying only 1 object with y==1),
or does the code ignore the creation of the new object assuming that we already have an object with the same name???
Sory if it is confuse, help pls.



LinkBack URL
About LinkBacks



and ty for the example iMalc