+=
also, how do you fix this error in C++?
Error2 error C2181: illegal else without matching if
What is this operator means means in C++?
The += means to add one to the variable on the left of the sign, and then see if it is equal to the value on the right on the sign.
The error means that somewhere you have an "else" in your program that is not matched with an if. Something like
if...
else...
if
else...
else...
The last "else" would cause that error because it has no matching "if".
Reply:+= is a replacement operator that adds the right-hand side of the operator to the left and stores the result back into the left-hand operator.
That error message means exactly what it says: there's an else that doesn't appear to have a corresponding if before it. This can easily happen if you use incorrect syntax. For instance:
if (a == b)
{
....
else
{
}
Hope that helps.
Reply:Monstly use with a counter or when you want to increment, for example int counter = 1;
counter += 5; really means counter = counter + 5;
The other compound assigments are -= /= *=
Reply:an operator in c++ is any of the mathematical operation which we do in it
e.g. +,-,*,/,% etc.
n abt tat error check if the 'else is used jst after ur 'if' block has ended....
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment