Code: Select all
planet* planArray = new planet[planetNum]; // in order to be able to do that you need
// to have a default constructor defined
for (int i = 0; i < planetNum; i++)
{
// you can use here setters the same way as the
// getters in the Star class
// just add void setXXXX methods to the Planet class
// for example
int dist = ...; // make calculations needed for the distance and than
planet[i]->setDistance(dist);
}
Code: Select all
void setDistance(int a)
{
distance = a;
}