c++在派生类构造函数中期望的主表达式
C++ expected primary expression before in derived class constructor
我知道很多这样的问题,但是没有一个能帮我解决我的问题。
这些是我的树中的构造函数。 tree.cpp: 我得到Tree();
Tree(string name, int season, int lifeTime, int height, int leafType);
Tree::Tree() : Plant()
{
this->lifeTime = 0;
this->height = 0;
this->leafType = -1;
}
Tree::Tree(string name, int season, int lifeTime, int height, int leafType) : Plant(string name, int season)
{
this->lifeTime = lifeTime;
this->height = height;
this->leafType = leafType;
}
expected primary-expression before name
错误。怎么解呢?
Plant(string name, int season)
需为Plant(name, season)
。你正在调用一个没有声明的函数,所以你没有在函数调用中包含参数类型。
相关文章:
- (C++)分析树以计算返回错误值的简单算术表达式
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 提升精神:解析布尔表达式并简化为规范范式
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 使用正则表达式regex_search在字符串中查找字符串
- 如何确认我的constexpr表达式实际上已经在编译时执行
- 概念中的cv限定符需要表达式参数列表
- 为什么constexpr的性能比正常表达式差
- Boost Accumulator_SET:期望主表达式
- 我有 3 个错误:期望一个")",期望一个表达式,long 类型的参数与 U32 类型的参数不兼容
- 预处理器定义函数期望表达式
- 错误C2057:期望的常量表达式
- 错误:')'令牌强制转换问题之前期望的主表达式
- 错误:当通过P2P通道连接两个NodeContainers时,期望主表达式在ns3中的const之前
- 试图为继承类的子类编写构造函数,猜测语法,期望的主表达式错误
- if语句中的函数:期望的错误表达式
- c++在派生类构造函数中期望的主表达式
- File.cpp:148:错误:期望的主表达式在`.不同的符号
- 在c++中期望主表达式在token之前
- c++期望的主表达式