看到 的人请帮帮忙啊
来源:互联网 发布:windows apache 编辑:程序博客网 时间:2024/05/01 17:34
#ifndef BOX_H
#define BOX_H
class Box
{
public:
Box(double lengthValue=1.0,double widthValue=1.0,double heightValue=1.0);
void showVolume() const;
virtual double volume() const;
protected:
double length;
double width;
double height;
};
#endif
#include <iostream.h>
#include "Box.h"
//constructor
Box::Box(double lv,double wv,double hv):length(lv),width(wv),height(hv)
{}
void Box::showVolume() const
{
cout<<"Box usable volume is "<<volume()<<endl;
}
double Box::volume() const
{
return length*width*height;
}
#ifndef CARTON_H
#define CARTON_H
#include <string>
#include "Box.h"
class Carton : public Box
{
public:
//construct ex
Carton(double lv,double wv,double hv,string material="Cardboard");
Carton(const Carton& aCarton);
~Carton();
double volume() const;
private:
string* pMaterial;
};
#endif
#include "Carton.h"
#include <cstring>
Carton::Carton(double lv,double wv,double hv,string material) : Box(lv,wv,hv)
{
pMaterial = new string (material);
}
Carton::Carton(const Carton& acarton);
{
length=aCarton.length;
width=aCarton.width;
height=aCarton.height;
pMaterial = new string(*aCarton.pMaterial);
}
Carton::~Carton ()
{
delete pMaterial;
}
double Carton::volume() const
{
double vol = (length-0.5)*(width-0.5)*(height-0.5);
return vol>0.0 ? vol : 0.0;
}
#ifndef TOUGHPACK_H
#define TOUGHPACK_H
#include "Box.h"
class ToughPack : public Box
{
public:
ToughPack(double lenghValue,double WidthValue,double heightValue);
double volume() const;
};
#endif
#include "ToughPack.h"
ToughPack::ToughPack(double lVal,double wVal,double hVal):Box(lVal,wVal,hVal){}
double ToughPack::volume() const
{
return 0.85*length*width*height;
}
#include <iostream.h>
#include "Box.h"
#include "ToughPack.h"
#include "Carton.h"
int main()
{
Box myBox(20.0,30.0,40.0);
ToughPack hardcase(20.0,30.0,40.0);
Carton aCarton(20.0,30.0,40.0);
cout<<endl;
myBox.showVolume();
hardcase.showVolume();
aCarton.showVolume();
cout<<endl;
return 0;
}
错误信息
/test2/carton.h(11) : error C2629: unexpected 'class Carton ('
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(11) : error C2238: unexpected token(s) preceding ';'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2143: syntax error : missing ';' before '*'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2501: 'string' : missing storage-class or type specifiers
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2501: 'pMaterial' : missing storage-class or type specifiers
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.cpp(5) : error C2061: syntax error : identifier 'string'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.cpp(5) : error C2511: 'Carton::Carton' : overloaded member function 'void (double,double,double)' not found in 'Carton'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(7) : see declaration of 'Carton'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.cpp(27) : fatal error C1004: unexpected end of file found
Test2.cpp
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(11) : error C2629: unexpected 'class Carton ('
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(11) : error C2238: unexpected token(s) preceding ';'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2143: syntax error : missing ';' before '*'
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2501: 'string' : missing storage-class or type specifiers
f:/智慧/c++程序/新建文件夹 (2)/test2/carton.h(16) : error C2501: 'pMaterial' : missing storage-class or type specifiers
f:/智慧/c++程序/新建文件夹 (2)/test2/test2.cpp(11) : error C2660: 'Carton::Carton' : function does not take 3 parameters
Error executing cl.exe.
- 看到 的人请帮帮忙啊
- 看到的人过来帮帮忙啊!!!纠结的触摸屏移植问题(为什么别人可以,我不行呢)
- 难题 !各位路过的请帮帮忙!
- 一个C++问题,请大家帮帮忙啊
- 急求一汇编程序 最基础的 请各位高人帮帮忙啊 小女子感激不尽
- 求设计一实用的小型通讯录,还请哪位大虾帮帮忙啊
- 求设计一实用的小型通讯录,还请哪位大虾帮帮忙啊
- JSP问题,请帮帮忙!
- 请大家帮帮忙!急
- 请高手帮帮忙!
- 请高手帮帮忙
- 请大家帮帮忙
- 请各位高手帮帮忙
- 请高手帮帮忙!!
- 请大家帮帮忙吧!
- 请各位帮帮忙
- JAVA调试的小问题,请各位高手帮帮忙!
- 请大家帮帮忙用C#怎么写下面的题目
- 如何学好Java的30个目标
- 企业级-软件测试规范流程
- 哈佛图书馆自习室墙上的训言
- 【译】Teach Yourself WPF in 24 Hours(Hour 3)
- 我要五分
- 看到 的人请帮帮忙啊
- 开始在pku acm切题…
- 公平
- 主流性能测试工具介绍
- Sqlsever存储过程总结
- 一个低学历者的辛酸程序路(载抄CSDN)
- C#中HashTable的使用
- 新生活
- c语言中static 用法总结