c++多文件结构

来源:百度知道 编辑:UC知道 时间:2024/05/18 11:09:31
time类头文件为:
class shape
{
public:
virtual float GetArea()=0
};
class Cirle :public shape
{
public:
Cirle (float r)
{
radius=r;
};
private:
float radius;
};

class Rectangle:public shape
{
public:
Rectangle (float len,float wid)
{
length=len;
width=wid;
}
private:
float length,width;
};
time源文件为:
#include "time"
using namespace std;
float Cirle::GetArea()
{
return pi*radius*radius;
}
float Rectangle::GetArea()
{
return length*width;
}
主函数文件为:
#include <iostream>
#include "time"
using namespace std;
const float pi=3.14;
int main()
{
float radius,length,width;
cout<<"请输入圆的面积:";
cin>>radius;
Cirle circlel(radius);
cout<<"圆的面积是:"<<circlel.GetArea()<<

#include "time.h"
time这个类找不到,真不知道你是怎么定义的

这位朋友你好,看了你的程序,想告诉你几句,写程序的扎扎实实的,你的错误很多都是粗心所致,我给你改了一下,有什么问题可以再给我联系,努力加油!
祝你好运!
time类头文件为:
class shape
{
public:
virtual float GetArea()=0;
};
class Cirle :public shape
{
public:
Cirle (float r)
{
radius=r;
}
float GetArea();
private:
float radius;
};

class Rectangle:public shape
{
public:
Rectangle (float len,float wid)
{
length=len;
width=wid;
}
float GetArea();
private:
float length,width;
};
time源文件为:
#include "time.h"
const float pi=3.14;
float Cirle::GetArea()
{
return pi*radius*radius;
}
float Rectangle::GetArea()
{
return length*width;
}
主函数文件为:
#include <iostream>
#include "time.h"
using namespace std;
int main()
{
float radius,l