BananEvgeniy 0 / 0 / 0 Регистрация: 04.12.2017 Сообщений: 7 |
||||
1 |
||||
16.12.2017, 00:40. Показов 38389. Ответов 14 Метки dev-c++ (Все метки)
Ругается на самую первую { что не так?
__________________
0 |
437 / 429 / 159 Регистрация: 21.05.2016 Сообщений: 1,338 |
|
16.12.2017, 01:21 |
2 |
int main() Добавлено через 38 секунд Добавлено через 53 секунды Добавлено через 42 секунды Добавлено через 3 минуты
0 |
3986 / 3255 / 910 Регистрация: 25.03.2012 Сообщений: 12,104 Записей в блоге: 1 |
|
16.12.2017, 01:37 |
3 |
int main(0);
0 |
0 / 0 / 0 Регистрация: 04.12.2017 Сообщений: 7 |
|
16.12.2017, 22:46 [ТС] |
4 |
все равно не помогает, может код неправильынй какой-то?я не сильно еще разбираюсь тут
0 |
wareZ1400 12 / 13 / 2 Регистрация: 11.01.2015 Сообщений: 208 Записей в блоге: 15 |
||||
16.12.2017, 22:58 |
5 |
|||
BananEvgeniy,
0 |
Kuzia domovenok 3986 / 3255 / 910 Регистрация: 25.03.2012 Сообщений: 12,104 Записей в блоге: 1 |
||||||||
17.12.2017, 00:17 |
6 |
|||||||
учи матчасть!
Добавлено через 1 минуту
int main() wareZ1400, ты точно прочитал этот коммент и переписал с учётом всех замечаний?
0 |
wareZ1400 12 / 13 / 2 Регистрация: 11.01.2015 Сообщений: 208 Записей в блоге: 15 |
||||
17.12.2017, 02:52 |
7 |
|||
Kuzia domovenok, точно прочитать коммент и переписал с учетом всех замечаний. Вот:
0 |
0 / 0 / 0 Регистрация: 04.12.2017 Сообщений: 7 |
|
17.12.2017, 21:53 [ТС] |
8 |
все равно не работает
0 |
0 / 0 / 2 Регистрация: 29.11.2017 Сообщений: 16 |
|
17.12.2017, 22:06 |
10 |
Ну правильно. Убери нахрен ; там где int main();
0 |
0 / 0 / 0 Регистрация: 04.12.2017 Сообщений: 7 |
|
17.12.2017, 22:46 [ТС] |
11 |
уже давно убрал, все равно ошибку пишет
0 |
Comevaha 0 / 0 / 2 Регистрация: 29.11.2017 Сообщений: 16 |
||||
22.12.2017, 20:24 |
12 |
|||
Берите код. Работает
0 |
12 / 13 / 2 Регистрация: 11.01.2015 Сообщений: 208 Записей в блоге: 15 |
|
24.12.2017, 01:37 |
13 |
Comevaha, а Вы каким компилятором компилите?
0 |
0 / 0 / 2 Регистрация: 29.11.2017 Сообщений: 16 |
|
24.12.2017, 14:20 |
14 |
Mingw
0 |
12 / 13 / 2 Регистрация: 11.01.2015 Сообщений: 208 Записей в блоге: 15 |
|
24.12.2017, 15:57 |
15 |
Comevaha, то, что я написал компилится в ms visual studio. А почему у других может не компилиться?
0 |
- Forum
- Beginners
- Expected unqualified-id
Expected unqualified-id
Hi, I’m having some issues with my code and I am getting some odd errors.
|
|
Please excuse the sloppy formatting.
Here are the errors I am receiving when I try to run the code:
|
|
I have no idea what they mean by «expected unqualified-id before», and every time I add the } before «else» in line 15, I just get more errors.
Any help would be greatly appreciated.
Last edited on
Remove the ; from line 13.
You have a semicolon on line 13 that shouldn’t be there.
16, 19, 22, 25 all require semicolons (before the brace but after the letter):
cond2 = 't' ; /*<--*/ }
Thanks for the help so far. I did what you guys said, and now I’ve gotten these errors:
|
|
So I get a few more of the expected unqualified-id errors, but in different lines now, and I’m still not entirely sure what this is supposed to mean.
Here’s the updated code, if it helps:
|
|
Last edited on
|
|
Missing ‘}’ at the end and a few other edits done.
Last edited on
You really need to work on indenting your code:
|
|
Thanks CaptainBlastXD, works with your edits. Greatly appreciate all the help guys.
Topic archived. No new replies allowed.
The expected unqualified id error shows up due to mistakes in the syntax. As there can be various situations for syntax errors, you’ll need to carefully check your code to correct them. Also, this post points toward some common mistakes that lead to the same error.
Go through this article to get an idea regarding the possible causes and gain access to the solutions to fix the given error.
Why Are You Getting the Expected Unqualified Id Error?
You are getting the expected unqualified-id error due to the erroneous syntax. Please have a look at the most common causes of the above error.
– Missing or Misplaced Semicolons
You might have placed a semicolon in your code where it wasn’t needed. Also, if your code misses a semicolon, then you’ll get the same error. For example, a semicolon in front of a class name or a return statement without a semicolon will throw the error.
This is the problematic code:
#include <iostream>
using namespace std;
class myClass;
{
private:
string Age;
public:
void setAge(int age1)
{
Age = age1;
}
string getAge()
{
return Age
}
}
– Extra or Missing Curly Braces
Now, if your code contains extra curly braces or you’ve missed a curly bracket, then the stated error will show up.
The following code snippet contains an extra curly bracket:
#include <iostream>
using namespace std;
class myClass;
{
private:
string Age;
public:
void setAge(int age1)
{
Age = age1;
}
}
}
– String Values Without Quotes
Specifying the string values without quotes will throw the stated error.
Here is the code that supports the given statement:
void displayAge()
{
cout << Your age is << getWord() << endl;
}
How To Fix the Error?
You can fix the mentioned unqualified-id error by removing the errors in the syntax. Here are the quick solutions that’ll save your day.
– Get Right With Semicolons
Look for the usage of the semicolons in your code and see if there are any missing semicolons. Next, place the semicolons at their correct positions and remove the extra ones.
Here is the corrected version of the above code with perfectly-placed semicolons:
#include <iostream>
using namespace std;
class myClass
{
private:
string Age;
public:
void setAge(int age1)
{
Age = age1;
}
string getAge()
{
return Age;
}
}
– Adjust the Curly Braces To Fix the Expected Unqualified Id Error
You should match the opening and closing curly braces in your code to ensure the right quantity of brackets. The code should not have an extra or a missing curly bracket.
– Wrap the String Values inside Quotes
You should always place the string values inside quotes to avoid such errors.
This is the code that will work fine:
void displayAge()
{
court << “Your age is” << getWord() << endl;
}
FAQ
You can have a look at the following questions and answers to enhance your knowledge.
– What Does a Qualified ID Mean?
A qualified-id means a qualified identifier that further refers to a program element that is represented by a fully qualified name. The said program element can be a variable, interface, namespace, etc. Note that a fully qualified name is made up of an entire hierarchical path having the global namespace at the beginning.
– What Does the Error: Expected ‘)’ Before ‘;’ Token Inform?
The error: expected ‘)’ before ‘;’ token tells that there is a syntax error in your code. Here, it further elaborates that there is an unnecessary semi-colon before the closing round bracket “).” So, you might get the above error when you terminate the statements that don’t need to be ended by a semi-colon.
– What Do You Mean By Token in C++?
A token is the smallest but important component of a C++ program. The tokens include keywords, punctuators, identifiers, etc. For example, you missed a semi-colon in your code because you considered it something that isn’t very important. But the C++ compiler will instantly show up an error pointing towards the missing “;” token.
Conclusion
The unqualified id error asks for a careful inspection of the code to find out the mistakes. Here are a few tips that’ll help you in resolving the given error:
- Ensure the correct placement of semicolons
- Aim to have an even number of curly brackets
- Don’t forget to place the text inside the quotes
Never write the code in hurry, you’ll only end up making more mistakes, and getting such errors.
- Author
- Recent Posts
Position Is Everything: Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL.