无法识别C++的多个函数
C++ Multiple Functions Not Recognized
这可能是一个非常简单的错误,但我创建了一个名为longin_page()的函数;
int login_page(string username,string password) {
无论如何,这是函数头,函数很长。然而,当我调用另一个文件中的函数(该函数被定义和引用到该文件)时,它似乎无法识别我定义的两个参数。
else if (input1 == "login") {
get_user_info();
login_page(file_username, file_password);
}
在VisualStudio中,我收到一个错误,说函数不接受两个参数。万一你想查看我的所有文件,它们都发布在下面。
login_page.cpp:
#include <iostream>
#include <Windows.h>
#include "login_page.h"
#include <string>
#include <fstream>
#include "profile_main_menu.h"using namespace std;
string file_username, file_password;
int get_user_info() {
ifstream user_info;
user_info.open("user_info.txt");
if (user_info.is_open()) {
user_info >> file_username;
user_info >> file_password;
cout << "File open" << endl;
cout << file_username << endl;
cout << file_password;
}
else {
cout << "Could not get info fro user_info.txt" << endl;
}
return 0;
}
int login_page(string username,string password) {
string username_input_2;
string password_input_2;
ifstream user_info;
user_info.open("user_info.txt");
string file_username, file_password;
if (user_info.is_open()) {
get_user_info();
}
else {
cout << "Error: No username and/or password found on user_info.txt" << endl;
login_page();
}
cout << "Please enter your username: " << endl;
cin >> username_input_2;
if (username == username_input_2) {
cout << username_input_2 << " , please enter your password." << endl;
cin >> password_input_2;
if (password == file_password) {
profile_main_menu();
}
else {
cout << "Passwords do not match. Please try again." << endl;
login_page();
}
}
else {
cout << "You do not have an account or you have misspeld your username. Please try again." << endl;
cout << username_input_2 << endl;
cout << username << endl;
login_page();
}
return 0;
}
login_page.h:
#define LOGIN_PAGE_H
int login_page();
int get_user_info();
initial_page_funct.cpp:(这是我得到错误的地方)
#include <iostream>
#include <string>
#include <Windows.h>
#include "login_page.h"
#include "create_account.h"
using namespace std;
extern string file_username, file_password;
int initial_login() {
string input1;
cout << "Welcome to AgentOS V230.20043." << endl;
Sleep(3000);
cout << "If you do not have an account and wish to create one, enter "create account"" << endl;
Sleep(3000);
cout << "If you do have an account, enter "login"" << endl;
getline(cin, input1);
if (input1 == "create account") {
create_account();
}
else if (input1 == "login") {
get_user_info();
login_page(file_username, file_password);
}
else {
cout << "You have not entered a knowned command. Please try again." << endl;
cout << "This is the command: " << input1 << endl;
initial_login();
}
return 0;
}
标头中的函数声明不正确。在login_page.h中替换
int login_page();
带有:
int login_page(string username,string password);
相关文章:
- "error: no matching function for call to"构造函数错误
- 什么时候调用组成单元对象的析构函数
- 继承函数的重载解析
- 为什么随机数生成器不在void函数中随机化数字,而在main函数中随机化
- C++模板来检查友元函数的存在
- 递归函数计算序列中的平方和(并输出过程)
- 对RValue对象调用的LValue ref限定成员函数
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 在C++STL中是否有Polyval(Matlab函数)等价物?
- 为什么使用 "this" 指针调用派生成员函数?
- 将对象数组的引用传递给函数
- 函数调用中参数的顺序重要吗
- 函数向量_指针有不同的原型,我可以构建一个吗
- 使用不带参数的函数访问结构元素
- 代码在main()中运行,但在函数中出现错误
- 内置函数可查看CPP中的成员变量
- 如何获取std::result_of函数的返回类型
- 如何在c++中为模板函数实例创建快捷方式
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗