hello guys...i just done my assignment and here's the code
#include <iostream>
using namespace std;
class CelestialBody
{
private:
double size;
public:
CelestialBody (double );
;
class Planet : public CelestialBody
{
private:
double orbit_time;
public:
Planet(double , double);
};
Class Earth : public Planet
{
private:
unsigned long int population ;
public:
Earth();
};
Celestialbody :: Celestialbody (double) :
size(SIZE)
{
cout<<"CelestialBody is called"<<endl;
}
Planet :: Planet (double) : size(SIZE) , orbit_time(ORBIT_TIME)
{
cout << "Planet constructor is called"<<endl;
Earth :: Earth ()
: Planet (1,40000), population (3000000000)
{
cout <<" Earth constructor is called."<<endl;
cout <<"Population =" <<population <<endl;
cout<<"orbit time = "<<orbit_time<< endl;
cout<< "size =" <<size <<endl;
int main ()
{
Earth earth;
return 0;
}
the output should be like this
CelestialBody constructor is called
Planet constructor is called
Population constructor is called
Population = 5000000000
orbit time = 1
size = 40000
but i am stuck in the earth class and constructor section.
I guess i was wrong in calling of the CelestialBody constructor to initialize the
data members of both the Planet and CelestialBody.
I didn't declared SIZE and ORBIT_TIME but it will not effect the end results will it?
any help plez..i did my homework..need for it to be compiled..