C++新手 急急急 高分求解 建了个工程文件后 在main不能打开其他.h和.cpp
project1.cpp#include<iostream>constdoublePI=3.14;#include<Graphics1.h>#include<Graphi...
project1.cpp
#include<iostream>
const double PI=3.14;
#include<Graphics1.h>
#include<Graphics1.cpp>
using namespace std;
int main ()
{
Rectangle rec(4,6);
cout<<"the rectangle Area is :"<<rec.Area()<<endl;
Circle cir(5);
cout<<"the cirdlr Area is :"<<cir.Area()<<endl;
Cylinder cyl(5,10);
cout<<"the Cylinder Area is:"<,cyl.Area()<<endl;
Sphere sph(5);cout<<"the sphere Area is:"<<sph.Area()<<endl;
return 0;
}
Graphics1.cpp
double Rectangle::Area()
{
return length*width;
}
double Circle::Area()
{
return PI*radius*radius;
}
double Cylinder::Area()
{
return 2*PI*radius*(radius+height);
}
double Sphere::Area()
{
return 4*PI*radius*radius;
}
Graphics1.h
//****Declaration class Rectangle****
class Rectangle
{
private:
int length;
int width;
public:
Rectangle():
length(1,width(2){}
Rectangle(int 1,int W):length (1),width(w);{}
~Rectangle() {}
double Area();
};
//8888888888888888888
class Circle
{
private:
int radius;
public:
Circle():radius(0){}
Circle(int r):radius(r){}
~Circle(){}
double Area();
};
//*********************
class Cylinder
{
private:
int radius,height;
public:
Cylinder():radious(1),height(2) {}
Cylinder(int r,int h):radius(r),height(h) {}
~Cylinder() {}
double Area ();
};
//*******
class Sphere: public circle
{
private:
int radius;
public:
Sphere():radius(1) {}
spere(int r):radius(r) {}
~Spere() {}
double Area ();
}; 展开
#include<iostream>
const double PI=3.14;
#include<Graphics1.h>
#include<Graphics1.cpp>
using namespace std;
int main ()
{
Rectangle rec(4,6);
cout<<"the rectangle Area is :"<<rec.Area()<<endl;
Circle cir(5);
cout<<"the cirdlr Area is :"<<cir.Area()<<endl;
Cylinder cyl(5,10);
cout<<"the Cylinder Area is:"<,cyl.Area()<<endl;
Sphere sph(5);cout<<"the sphere Area is:"<<sph.Area()<<endl;
return 0;
}
Graphics1.cpp
double Rectangle::Area()
{
return length*width;
}
double Circle::Area()
{
return PI*radius*radius;
}
double Cylinder::Area()
{
return 2*PI*radius*(radius+height);
}
double Sphere::Area()
{
return 4*PI*radius*radius;
}
Graphics1.h
//****Declaration class Rectangle****
class Rectangle
{
private:
int length;
int width;
public:
Rectangle():
length(1,width(2){}
Rectangle(int 1,int W):length (1),width(w);{}
~Rectangle() {}
double Area();
};
//8888888888888888888
class Circle
{
private:
int radius;
public:
Circle():radius(0){}
Circle(int r):radius(r){}
~Circle(){}
double Area();
};
//*********************
class Cylinder
{
private:
int radius,height;
public:
Cylinder():radious(1),height(2) {}
Cylinder(int r,int h):radius(r),height(h) {}
~Cylinder() {}
double Area ();
};
//*******
class Sphere: public circle
{
private:
int radius;
public:
Sphere():radius(1) {}
spere(int r):radius(r) {}
~Spere() {}
double Area ();
}; 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询