hello guys...i just done my assignment and here's the code
the output should be like thisCode:#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; }
all looks fine butCode: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 think i was mistaken in the area of 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..



LinkBack URL
About LinkBacks


