I have the following, rather stupid question
I made a parent class called "Space" with a name (eg. sun) and a weight (float).
Then i made a child class called "Planet" with a datamember "Space turnaround" (example, the earth-planet turns around the sun-space)
I made a constructor :
a getTurnaround function :Code:Planet(char*="",float=0.0,Space);
now my problem is, i don't know how I should write the Planet-constructor. I was thinking something like :Code:Space & getTurnaround (void) const;
and for the getTurnaround :Code:Planet::Planet(d):Space(n,f) { name= new char[strlen (n) +1]; strcpy(name,n); weight= f; turnaround= d; //would requere a friend operator= if im not mistaking }
But I expect a lot of mistakes in this, since this is my first experience with passing classes.Code:Space Planet::getTurnaround(void) const { return turnaround; }
Hope someone can help.



LinkBack URL
About LinkBacks



