error: overloaded 'operator=' must be a non-static member function
This bitch does not allow me to implement custom operator= for class that I can't modify(well, I can apt-get source or modify header files but it's too dirty).
I can overload += as static non-member function just fine.
So in other words, if I need to use Library1 that provides Vector3 and Library2 that provides VecXYZ and these libraries do not know about existence of each other I can write additional functions so vector3+vecXYZ,vector3+=vecXYZ will work but assignment is no-no. Thou shalt not write functions for converting one type of vectors to another.
WTF? Where is justice?
Name:
Anonymous2012-02-05 11:27
No one here gives a fuck about your lame attempt at a nerd adventure with a loser language.
Name:
Anonymous2012-02-05 11:48
>>2
Both Haskell and Lisp are shit. C is undefined shit.
Name:
Anonymous2012-02-05 12:21
>>1
If C++ is too hard, you should consider Visual Basic.
WTF? Where is justice?
Eh..? It's a programming language, not some justice system. You have to follow certain rules with every programming languages. If there were justice, you would be in electric chair for trying to overload operators so recklessly.
Name:
Anonymous2012-02-05 13:05
Write a wrapper class.
Name:
Anonymous2012-02-05 14:09
Why are you even trying to use operator overloading? It's some real stupid shit.
You cannot overload ?:
I have a project that heavily depends on that and coding workarounds is just a nightmare.
Name:
Anonymous2012-02-06 18:52
>>13 I have a project that heavily depends on that and coding workarounds is just a nightmare.
Then your project is absolute shit, it's a complete piece of fucking crap.
Name:
Anonymous2012-02-06 19:01
>>13
Just overload operator bool() for the condition's type and make sure the second and third parts of the ?: are always the same type. If you're trying to give ?: any meaning other than a conditional operator then you're using it wrong.
Name:
Anonymous2012-02-06 19:05
>>14
Well thank you. If you cannot imaging a project using such arithmetic then it is more of a reflection of your own shortcoming.
Name:
Anonymous2012-02-06 19:09
This just sounds like some lame nerd adventure in a loser language that no one here gives a shit about.
Simply use the friend operator to break all conventions about information hiding and object oriented programming.
Name:
Anonymous2012-02-07 13:22
I can't believe the retardation of OP. Consider a situation where you'd be using both vector types. Now imagine how INCREDIBLY FUCKING CONFUSING it would be for anyone else (and YOU) reading your program, to see a vector that is obviously of type VecXYZ, being assigned the value of a Vector3.
operator= in C++ is for assigning values, not for implicit typecasting. It's people like you have given operator overloading the bad rap it has. If you want to convert VecXYZ to Vector3, write a vecXyzToVector3() function.