If I continue using CodeBlocks , one day I will kill myself
Use notepad to type, compile from command line. Error messages will be the same though.
That is because you declared operator>> as a member function in your class and defining it as a freestanding one.
Either move declaration out of class and make it accept two arguments or declare it within class and define it as a class function (same way as you defining constructors and other member functions)
I must say that overloading operators without saving their semantics is a bad design. In your case it would better be a function swapNames(tmp1, tmp2) or tmp1.swapName(tmp2)
As far as an IDE, I recommend at least TRYING Visual Studio (or Visual Express or another one of its releases).
Concerning your overload: << and >> are (depending on context) bitwise shift, or stream operators. It may be misleading to overload them to do something else.
I see no reason to overload an operator here - why not just define a switchName method or something?
THANK YOU!
I'm just learning classes and how they work.
I have no reason for writing that. I'm just stuck in overloading operaotors.
I have no problem if I want to write that with a function.
I think the problem is with the example I'm trying to write.
I should write something else.
And @MiiNiPaa sorry for the thing I said about CodeBlocks.
I think you like it a little.
Actually I was pointing out that IDE have no relation to the compiler and language standards.
Concerning your overload: << and >> are stream operators. It may be a little misleading to overload them to do something not related to a stream. Having not tried it, I'm not sure if it's even possible.
a) They are bitwise shift operators which were used for some obscure reason to be an stream manipulation operators.
b) It is possible to give them any meaning you want.
c) As you said it is misleading for anyone who will be reading your code. Java forbids operator overloading because of that.