[英]expected primary-expression before ' '
So I have a class and a derived class.所以我有一个类和一个派生类。 Both need to have constructors but the problem is I get errors for the derived class' constructor.两者都需要有构造函数,但问题是派生类的构造函数出现错误。
class Property : public Space
Property::Property(int id, string name, SpaceType type, string actionText, int buyCost, int upgradeCost, PropertyCategory category): Space(int id, string name, SpaceType type, string actionText)
{
this->buyCost = buyCost ;
this->upgradeCost = upgradeCost ;
this->category = category ;
numberOfHouses = 0 ;
}
In constructor 'Property::Property(int, std::string, SpaceType, std::string, int, int, PropertyCategory)':|在构造函数中'Property::Property(int, std::string, SpaceType, std::string, int, int, PropertyCategory)':|
error: expected primary-expression before 'int'|错误:'int' 之前的预期主表达式|
error: expected primary-expression before 'name'|错误:'name' 之前的预期主表达式|
error: expected primary-expression before 'type'|错误:'type' 之前的预期主表达式|
error: expected primary-expression before 'actionText'|错误:'actionText' 之前的预期主要表达式|
Just call superclass constructor with parameters:只需使用参数调用超类构造函数:
Property::Property(int id, string name, SpaceType type, string actionText, int
buyCost, int upgradeCost, PropertyCategory category): Space(id, name, type, actionText)
{
this->buyCost = buyCost ;
this->upgradeCost = upgradeCost ;
this->category = category ;
numberOfHouses = 0 ;
}
#include <iostream>
using namespace std;
class loginManager
{
public:
string IDNumberattempt;
string Yournameattempt;
loginManager()
{
string accessGranted=0;
}
void login()
{
cout<<"________________________________________________________________________________\n";
cout<<" ///////////////BATANG PASAWAY\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\""\n";
cout<<"________________________________________________________________________________\n";
cout<<" WELCOME TO BACHELOR OF SCIENCE IN INDUSTRIAL AUTOMATION & MECHATRONICS\n\n";
cout<<" Mindanao State University - Iligan Institute of Technology\n\n";
cout<<"\n S.Y. 2018-2019";
cout<<"\n\n\n";
cout<<" PROJECT CREATED BY STUDENT OF BSIAM\n\n";
cout<<"\n\n";
cout<<" SIGN IN FOR ATTENDACE:\n\n";
string IDnumber;
cout<<"Please Input your IDnumber and Name\n";
cout<<"IDnumber:";
cin>>IDNumberattempt;
if(IDNumberattempt==IDnumber)
{
string Name;
cout<<"Name:";
cin>>Yournameattempt;
if(Yournameattempt==Name)
{
cout<<"hey You're Logged In.";
}
}
private:
string Name = "Admin"
string ID Number = "2018-5844";
bool accessGranted;
};
int main()
{
loginManager loginManagerObj;
loginManagerObj.login();
}
}
;
help me with this pls 请帮助我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.