Here is an example of the difference.:)
#include <iostream>
int main()
{
std::string s1( "Hello " );
std::string s2( "Hello " );
s1 += "World!";
s2 =+ "World!";
std::cout << s1 << std::endl;
std::cout << s2 << std::endl;
}
The program output is
Hello World!
World!
Operator +=
is the compound assignment operator that indeed exists in C++ (and many other languages). As you can see in C++ it can be even overloaded for example for standard class std::string
.
Symbols =+
are two operators: the assignment operator = and unary plus operator +. In the demonstrative program the unary plus operator applied to ths string literal has no effect.
Here is a demonstrative program of other weird operators.:)
#include <iostream>
int main()
{
int x = 1;
int y = 1;
int z = 1;
if ( x --- y +++ z --> 0 ) std::cout << z << std::endl;
return 0;
}