Lewissi
22/09/2005, 23:09
#include<iostream>
#include<cstring>
using namespace std;
using std::string;
class Planet{
private:int moons;
double dist_sun;
double diameter;
double mass;
public:
Planet(int,double,double,double);
~Planet();
void show();
};
Planet::Planet(int a, double b,double c,double d){
moons=a;
dist_sun=b;
diameter=c;
mass=d;
}
Planet::~Planet(){
}
void Planet::show(){
cout<<moons<<endl<<dist_sun<<endl<<diameter<<endl<<mass<<endl;
}
class Mars:public Planet{
private:
string color;
public:
Mars(int,double,double,double,string);
~Mars();
};
Mars::Mars(int e,double f,double g,double h,string cl):moons(e),dist_sun(f),diameter(g),mass(h)
{
color=cl;
}
Mars::~Mars(){
}
Mars::show()
{
Planet::show();
cout<<color<<endl;
}
int main()
{
Mars ebe(1,12.1,40.2,21.3,"red");
ebe.show();
return 0;
}
#include<cstring>
using namespace std;
using std::string;
class Planet{
private:int moons;
double dist_sun;
double diameter;
double mass;
public:
Planet(int,double,double,double);
~Planet();
void show();
};
Planet::Planet(int a, double b,double c,double d){
moons=a;
dist_sun=b;
diameter=c;
mass=d;
}
Planet::~Planet(){
}
void Planet::show(){
cout<<moons<<endl<<dist_sun<<endl<<diameter<<endl<<mass<<endl;
}
class Mars:public Planet{
private:
string color;
public:
Mars(int,double,double,double,string);
~Mars();
};
Mars::Mars(int e,double f,double g,double h,string cl):moons(e),dist_sun(f),diameter(g),mass(h)
{
color=cl;
}
Mars::~Mars(){
}
Mars::show()
{
Planet::show();
cout<<color<<endl;
}
int main()
{
Mars ebe(1,12.1,40.2,21.3,"red");
ebe.show();
return 0;
}