无法将引用从一个类传递到另一个类
Unable to pass reference from one class to another
我正在编写一个c++程序,用于管理一个单位中的资源和职责。此程序旨在在Linux Shell中运行。
我创建了一个类调用主页供用户登录。我还有另一个类叫SelectionPage。这些是用户登录后的菜单。在我的主函数中,我希望将主页类的一个实例获得的一些数据传递给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
这是我的main()
// 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;
}
有人能帮帮我吗?我会感激不尽的!
仔细查看错误信息。
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()
编译错误的原因。
其他两个编译错误的原因可能是)
和{' in the definition of
之间的虚假;
SelectionPage::SelectionPage '。把它删掉
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 运行同一解决方案的另一个项目的项目
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- C++从另一个类访问公共静态向量的正确方法是什么
- C++-试图将函数指针推回到另一个CPP文件中的矢量时出错
- 使用std::transform将一个范围的元素添加到另一个范围中
- 输入到文件并输出到另一个文件,并将流文件传递给函数
- 我可以将一个用clang c++11编译的对象与另一个用c++17编译的对象链接起来吗
- 修改函数中的指针(将另一个指针作为参数传递)
- 为什么我不能将一个对象push_back到属于另一个类的对象向量中?
- C++试图读取一个文件并输出到另一个文本文件
- 如何将指针从一个void函数传递到另一个C++
- 如何从另一个文件继承私有成员变量和公共函数
- 使用.find函数在c++中查找字符和另一个字符之间的大小
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 在他自己的方法中,有可能将一个对象取消引用到另一个对象吗
- C++-我可以创建另一个类的成员并在构造函数中使用它吗
- 如何在C++中将函数发送到另一个进程
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口