[错误]期望在'{'标记之前的unqualified-id [英] [Error] expected unqualified-id before '{' token
本文介绍了[错误]期望在'{'标记之前的unqualified-id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
using namespace std;
int main();
string username,password,un,pw;
//string username,password
{
int choice;
cout<<"1: Registration\n2: Login\nYour choice: " ;
cin>>choice;
if (choice ==1)
{
cout<<"Select a username: " ;cin>>username;
cout<<"Select a pssword: " ;cin>>password;
}
else if (choice == 2)
{
if (username == un && password == pw)
{
return true;
}
else
{
return false;
}
}
}
我尝试过:
尝试判断错误究竟是什么错误但不能得到它。
请帮助
What I have tried:
Try To fine what exactly the error but not get it.
pls help
推荐答案
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
using namespace std;
int main(); // 1) no ';' here
// 3) here
string username,password,un,pw;
//string username,password
{ // 2) the '{' goes at 3)
int choice;
cout<<"1: Registration\n2: Login\nYour choice: " ;
cin>>choice;
if (choice ==1)
{
cout<<"Select a username: " ;cin>>username;
cout<<"Select a pssword: " ;cin>>password;
}
else if (choice == 2)
{
if (username == un && password == pw)
{
return true;
}
else
{
return false;
}
}
}
按编号顺序阅读评论。 1 2 3
read comments in number order. 1 2 3
这篇关于[错误]期望在'{'标记之前的unqualified-id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文