adress* classarray = new adress[1]; adress x; for (int i = 0; i < 2; i++) { x = classarray[i]; cout << x.age << "\n"; } delete classarray;
You do not need to copy it into x. This will waste time and memory. You can just say classarray[i].age
If the amount of a class won't change you can use an array method like mine. The method above is good if the class/struct will be created and deleted often.