[英]C++ expected primary expression before in derived class constructor
I know a lot of questions named just like this, but any of them couldn't help me to solve my problem. 我知道很多这样的问题,但是其中任何一个都无法帮助我解决问题。
These are the constructors in my tree.h: 这些是我的tree.h中的构造函数:
Tree();
Tree(string name, int season, int lifeTime, int height, int leafType);
And these are their implementations in tree.cpp: 这些是它们在tree.cpp中的实现:
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;
}
I am getting expected primary-expression before name
error. 出现
expected primary-expression before name
错误expected primary-expression before name
我正在获得expected primary-expression before name
。 How can I solve that? 我该如何解决?
Plant(string name, int season)
needs to be Plant(name, season)
. Plant(string name, int season)
必须为Plant(name, season)
。 You are calling a function not declaring one so you don't include the parameters type in a function call. 您正在调用的函数没有声明一个,因此您不将参数类型包括在函数调用中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.