The error message is a bit cryptic but it means that it expects an identifier (a name) before the { symbol.
If you look at what's before the { symbol (on the line above) you find that there is a semicolon that shouldn't be there.
It would be so much easier for both you and us to see the problems with your code if it were properly formatted.
2) The following lines look dodgy to me:
1 2
void swap (second &)
}
I suspect there's a missing semicolon there.
3) In the following lines:
1 2
class first;
{
That semicolon shouldn't be there.
i m try many things but this error appear in my every programm when i go compile so i m not able tp complete any programm.
That probably means there's something fundamental about C++ syntax that you haven't understood and learnt, so you're making the same mistakes over and over.
From the looks of the errors I have spotted, it looks as though you haven't properly learned the syntax for class definitions, method declarations, and method definitions. In particular, you should learn where you need to put semicolons, and where you need to not put semicolons.
thanks to tell me but when i do change but my expected unqualified-id before '{' token error not gone. and when i remove class first ; semicolon so its give another error.[Error] expected ';' after class definition. when i put again that semicolon so its solve.
Line 5,20: Extraneous ;
Line 18: Missing a ; (or a function body)
Line 19: Missing ; to terminate the class.
Line 27: Capitalization error.
Line 33: ; belongs after the ), not before
Line 40,53: Extraneous ;
Line 41: main() must be type int
Line 52: Missing ;
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
ok now only tell me what semicolon i erase and where i put semicolon to correct this programme. i want to know and learn how i sovle expected unqualified-id before '{' token error.
thanks for help.
A couple of examples: return 0 semicolon missing cin>>X>>y;x should be lower-case.
I pointed out these two errors two days ago, but they are still not fixed. I think you should at least make some effort to follow the help given by others such as AbstractionAnon too. The code won't magically fix itself if you're not prepared to even try.
like u said chervil. i change many things and its help. but my first error still there. its point curser line 6 and 19 line. expected unqualified-id before '{' token error. so i try many other token but i don't understand which token id its taking about.
#include<iostream>
// #include<conio.h>
usingnamespace std ;
class second;
class first // ; *** remove the semicolon here
{
int a,b;
public :
void get ()
{
cout<<"\n enter a&b";
cin>>a>>b;
}
void show()
{
cout<<"\n"<<a<<b;
}
void swap(second &);
};
class second // ; *** remove the semicolon here
{
int x,y;
public:
void get()
{
cout<<"\n enter x&y";
cin>>x>>y;
}
void show()
{
cout<<"\n"<<x<<y;
}
friendvoid first::swap(second &);
};
void first::swap(second & s)
{
int t;
t=a;
a=s.x;
s.x=t;
t=b;
b=s.y;
s.y=t;
} // ; *** remove the semicolon here
// void main(int)
int main() // main must return int
{
first f1;
second s1;
f1.get();
s1.get();
f1.show();
s1.show();
f1.swap(s1);
f1.show();
s1.show();
return 0;
}
thanks to all and thanks jL becaus u tell me things very clearly with comment so i understand and now my programme compile without error thanks.
can u tell me i put semicolon class first and class second that's why he give me unqualified-id before '{' token error. because i want to know so if that error appear again in my other programme so i m able to solve it. thanks
You need to understand the difference between a class definition, and a forward declaration of a class. Your textbook should clearly show the difference in syntax, and, specifically, where to put semicolons in each case.