我正在编写一个C ++程序,旨在管理公寓中的资源和职责。 该程序旨在在Linux Shell中运行。
我创建了一个类调用HomePage供用户登录。我还有另一个名为SelectionPage的类。用户通过登录后的菜单是哪个。在我的主要函数中,我希望将HomePage类的实例获得的一些数据传递给SelectionPage类的实例。
我被困在这里至少6个小时,有人可以帮忙吗?
以下是错误消息:
g++ C_Main.cpp C_HomePage.cpp C_SelectionPage.cpp -o Project
C_Main.cpp: In function ‘int main()’:
C_Main.cpp:17:93: error: no match for call to ‘(std::vector<std::basic_string<char> >) ()’
C_Main.cpp:17:122: error: no match for call to ‘(std::vector<std::basic_string<char> >) ()’
C_HomePage.cpp:290:41: error: no ‘std::vector<std::basic_string<char> > HomePage::getDutiesList()’ member function declared in class ‘HomePage’
C_HomePage.cpp:294:44: error: no ‘std::vector<std::basic_string<char> > HomePage::getResourcesList()’ member function declared in class ‘HomePage’
C_SelectionPage.cpp:9:144: error: declaration of ‘SelectionPage::SelectionPage(std::string, int, std::vector<std::basic_string<char> >, std::vector<std::basic_string<char> >, std::string)’ outside of class is not definition
C_SelectionPage.cpp:9:146: error: expected unqualified-id before ‘{’ token
make: *** [Project] Error 1
这是我的主要()
// Testing Home Page Functionality
#include "H_HomePage.h"
#include "H_SelectionPage.h"
using namespace std;
string initializationFile = "D_initialization.dat";
string flatMemberFile = "D_flatMember.dat";
int main()
{
HomePage frontEnd(initializationFile); //Create Boundary Object
system("clear"); //Clear Terminal Screen
frontEnd.login(flatMemberFile);
SelectionPage Menu(frontEnd.getManager(), frontEnd.getInitPoints(), frontEnd.getDutiesList(), frontEnd.getResourcesList(), frontEnd.getLoginName());
Menu.showManagerMenu();
return 0;
}
这是SelectionPage类的构造函数,如头文件中所述:
...
SelectionPage(string Manager, int Points, vector <string> dutiesList, vector <string> resourceList, string loginName);
...
这是SelectionPage类的构造函数的实现:
SelectionPage::SelectionPage(string newanager, int points, vector <string> newDutiesList, vector <string> newResourceList, string newLoginName);{
manager = newManage;
initPoints = points;
dutiesList = newDutiesList;
resourceList = newResourceList;
loginName = newLoginName;
}
有人可以请,请帮忙吗?我会非常感激的!
答案 0 :(得分:0)
仔细查看您的错误消息。
C_HomePage.cpp:290:41: error: no ‘std::vector<std::basic_string<char> > HomePage::getDutiesList()’ member function declared in class ‘HomePage’
C_HomePage.cpp:294:44: error: no ‘std::vector<std::basic_string<char> > HomePage::getResourcesList()’ member function declared in class ‘HomePage’
您可能对HomePage::getDutiesList()
和HomePage::getResourcesList()
的声明不正确,或者根本没有声明。在不查看类声明的情况下,很难说出它们到底出了什么问题。这也是main()
中编译器错误的原因。
其他两个编译器错误的原因可能是;
和)
SelectionPage :: SelectionPage`之间的虚假{' in the definition of
。摆脱它。