导入派生类只能导入一个
Importing derived classes can only import one
如何导入多个派生类标头(不收到错误(?
我有一艘基础船。我有2个派生的课程,货物和游轮。在我的主要课程中,我尝试导入货物和巡航的标题文件。如果我两者都导入,我会发现一个错误;如果我导入一个,没有错误。
我对多个进口的尝试:
include "CruiseShip.h"
include "Cargoship.h"
错误列表:
1>c:userscorysourcereposproject33project33ship.h(7): error C2011: 'Ship': 'class' type redefinition
1>c:userscorysourcereposproject33project33ship.h(7): note: see declaration of 'Ship'
1>c:userscorysourcereposproject33project33cargoship.h(7): error C2504: 'Ship': base class undefined
我的船基类:
#include "Ship.h"
Ship::Ship() {
}
Ship::~Ship() {
}
Ship::Ship(string name, string year) : shipName(name), shipYear(year) {
}
string Ship::getShipName() {
return shipName;
}
string Ship::getShipYear() {
return shipYear;
}
void Ship::setShipName(string name) {
shipName = name;
}
void Ship::setShipYear(string year) {
shipYear = year;
}
string Ship::print() const {
return "Ship Name: " + shipName + " nYear Built: " + shipYear;
}
不使用基类标题文件上的guards:
https://en.wikipedia.org/wiki/include_guard
相关文章:
- 如何在安卓工作室中将c ++头文件从一个文件夹导入到另一个文件夹?
- 从文件导入数据时遇到问题.我有一个没完没了的循环
- 使用 GDAL 将 DXF 块从一个文件导入到另一个文件
- 导出从另一个模块导入的类
- 我想用 c++ 运行一个 vtk 示例,但我不知道如何导入所需的数据
- 如何修复库中的"invalid use of non-static member function" 导入另一个库
- 导入派生类只能导入一个
- 我应该把Boost.Python的.so文件放在哪里,这样我就可以把它作为一个模块导入,以及我如何将它与Python 2
- 如何将包含多个.cpp源文件的文件夹导入Eclipse项目中,每个源文件都有一个main()定义
- 在C++中嵌入Python:在Python脚本中导入模块在一个函数调用过程中有效,但在另一个调用过程中无效
- 如何在另一个C 标头文件中导入类
- 在另一个应用程序中嵌入python时,如何在子模块(即scipy.optimize.nnls)中导入或调用函数
- 如何从一个文件中读取数据并将其导入另一个文件
- 如何多行一个#导入
- 将一个 dll 导入另一个 dll C++
- 如何将C++ dll 导入和使用/运行到另一个 C# 项目中
- QLibrary-导入一个类
- 将dll文件导入另一个IDL文件
- 寻找一个代码解决方案来导入.mdb表到另一个.mdb表
- Boost Python导入一个带有std::vectors作为参数的c++函数