C++ 智能感知:标识符“;“用户存在”;在我的Visual Studio c+中未定义+;项目
我有一个头文件BookStore.header,我在其中创建了一个类Users,带有私有属性:C++ 智能感知:标识符“;“用户存在”;在我的Visual Studio c+中未定义+;项目,c++,intellisense,C++,Intellisense,我有一个头文件BookStore.header,我在其中创建了一个类Users,带有私有属性: int id_user; char* u_name; char* email; char password[20]; static unsigned int nr_user; getter、setter、构造函数、析构函数和 User(const User&); User &operator=(const User&); friend istream
int id_user;
char* u_name;
char* email;
char password[20];
static unsigned int nr_user;
getter、setter、构造函数、析构函数和
User(const User&);
User &operator=(const User&);
friend istream &operator>> (istream &, User&);
friend ostream &operator<< (ostream &, User);
bool isLogIn();
bool userexist(ifstream& , User& );
int get_users_count(ifstream &);
我的问题是在主课上,包括“BookStore.h”
{
cin>>u5;
河流充填;
infle.open(“users.txt”);
如果(!userexist(infle,u5)){
infle.open(“users.txt”);
int numbers\u id=获取用户数(infle);
u5.设置\u id(&编号\u id);
outFile编译是否失败?IntelliSense可能不是最新的(例如:代码未分析等)。您的文件是否真的命名为BookStore.header
?(它应该是BookStore.h
,与include
使用的名称相同)
bool User::isLogIn(){
string username, password, file_line;
cout << "enter username:";
cin >> username;
cout << "enter pass:";
cin >> password;
ifstream infile;
infile.open("users.txt");
if (!infile.is_open()){
cout << "Error while opening the file...";
}
else{
string str;
while (getline(infile, str)){
vector<string> newVector = split(str);
/*for (string line; getline(infile, line);)
{*/
string username_from_file = newVector[1];
string password_from_file = newVector[3];
if ((username_from_file.compare(username) == 0) && (password_from_file.compare(password)) == 0){
return true;
}
/*}*/
}
}
return false;
/* if (un == username&& pw == password){
return true;
}
else
return false;
}*/
}
bool userexist(ifstream& file, User& u){
string str;
while (getline(file, str)){
vector<string> newVector = split(str);
cout << newVector.size();
if (newVector.size() > 0){
string username_from_file = newVector[1];
if ((username_from_file.compare(u.getName()) == 0)){
file.close();
return true;
}
}
}
file.close();
return false;
}
int get_users_count(ifstream &file){
string str;
int i = 0;
while (getline(file, str)){
vector<string> newVector = split(str);
if (newVector.size() > 0){
string iduser = newVector[0];
i++;
}
}
file.close();
return i;
}
{
cin >> u5;
ifstream infile;
infile.open("users.txt");
if (!userexist(infile, u5)){
infile.open("users.txt");
int numbers_ids = get_users_count(infile);
u5.set_id(&numbers_ids);
outFile << u5.get_id() << " " << u5.getName() << " " << u5.getEmail() << " " << u5.getPass() << " " << endl;
//outFile << u5;
cout << "Registration succesfull!";
cout << endl;
outFile.close();
}