#ifndef BBOARD_H
#define BBOARD_H
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class User{
};
class Message{
};
class BBoard{
private:
string title;
vector<User> user_list;
User current_user;
vector<Message> message_list;
public:
BBoard();
BBoard(const string &ttl);
void setup(const string &input_file);
void login();
void run();
private:
bool user_exists(const string &name, const string &pass) const;
};
#endif
cpp文件
#include "BBoard.h"
#include <fstream>
#include <algorithm>
using namespace std;
User user_l;
BBoard::BBoard(){
title = "Hello World";
vector<User> user_list;
User current_user;
vector<Message> message_list;
}
BBoard::BBoard(const string &ttl){
title = ttl;
}
void BBoard::setup(const string &input_file){
ifstream fin;
fin.open("users1.txt");
while(!fin.eof()){
user_list.push_back(user_l);
}
}
bool BBoard::user_exists(const string &name, const string &pass) const{
vector<User>::iterator i = find(user_list.begin(), user_list.end(), name);
}
void BBoard::login(){
string sn, pw;
cout << "Welcome to " << title << endl;
bookmark:
cout << "Enter our username ('Q' or 'q' to quit): ";
getline(cin, sn);
cout << "Enter your password: ('Q' or 'q' to quit): ";
getline(cin, pw);
}
我user_exists功能不斷給出關於沒有合適的用戶定義的轉換錯誤。我試圖使用user_exists來檢查用戶名和密碼,如果它存在,它將返回true。
也許你應該告訴我們**確切**錯誤。 – 0x499602D2