why when I try to compile this
I get:Code:test& operator~ (const test& b1, const test& b2);
error: âtest& Htest::operator~(const test&, const test&)â must take âvoidâ
Printable View
why when I try to compile this
I get:Code:test& operator~ (const test& b1, const test& b2);
error: âtest& Htest::operator~(const test&, const test&)â must take âvoidâ
operator~ is a unary operator. Therefore, if it is overloaded as a member function, it must have take no arguments. If it is overloaded as a free function, it must take exactly one argument.
and does it return a test& or a test? a reference or a value?
Most likely it would return by value. (But of course there are exceptions for exceptional semantics.)
how about this one:
I get this error:Code:type& operator~=();
:35: error: expected primary-expression before â)â token
:35: error: declaration of âoperator~â as non-function
operator~= is a binary function.
so it should take two arguments you mean?
You cannot overload ~= because it's not a valid operator in C++. You can only overload (most of) the operators that already come with the language.
Yes, that is correct.Quote:
Originally Posted by Ronix
By the way, -EquinoX-, I really suggest that you post the smallest and simplest program that demonstrates the error.