我有这个:
// Get the Application Constructor Vector
vector<ApplicationConstructor> Application::getAppConstructorVector(){
return this->AppConstructorVector;
}
此处Application是一个抽象类,带有一个名为ShowData()
的抽象方法:
void DesktopApplication::ShowData() const{
cout << "-------------------------AppConstructor Details----------------------------------------------" << endl;
vector<ApplicationConstructor> appConstructorVector = this->getAppConstructorVector();
for (int i= 0; i < appConstructorVector.size(); i ++)
{
cout << "Contructor Code: " << appConstructorVector.at(i).getConstructorCode()
<< "Name: " << appConstructorVector.at(i).getConstructorName()
<< "Email: " << appConstructorVector.at(i).getConstructorEmail()
<< endl;
}
}
其中desktopApplication
扩展了Application并实现了抽象方法Showdata()
我有这个:
void AppSystem::ShowData(const Application &app){
app.ShowData();
}
其中AppSystem是具有vector<Application *> &ApplicationVector;
属性的类
基本上我有这个
GameApplication app1(true, "Puzzle", (char *)"game1456", "Tetris", "1.0.0", appConstructor1, 10.0);
GameApplication *appPtr1 = &app1;
AppSystem appSystem;
appSystem.PushAppToApplicationVector(appPtr1);
appSystem.ShowData(*appPtr1);
我明白了:
错误:将“ const DesktopApplication”作为“ this”参数传递 限定词[-fpermissive]尽管我称GameApplication showData()不是DesktopApplication之一。有什么建议吗?