when we overloading a function: what matters is only the argument list(inclued the types) or the return type too?
i'm overloading the assigment operator, but seems that i can't use with diferent return types:(
please someone explain to me
cambalinho 142 Practically a Posting Shark
Recommended Answers
Jump to PostOverloading (of function or operators) is done only with the parameters, not the return type. If you have two function with the same name (or operator), same parameters and a different return type, the compiler is going to say that the call is ambiguous (it cannot choose between the two …
Jump to PostThat does not make any sense. The assignment operator has to be a member function of the class that is on the left-hand-side of the = sign. Please provide the class declaration in which these operators are defined.
Jump to PostIn this case, you don't need the assignment operator at all. The default (compiler-generated) version is going to work just fine. This is because your only data member in the Variant class is the string
result
, which is correctly copied in the default assignment operator.
All 10 Replies
Slavi 94 Master Poster Featured Poster
A Haunted Army 0 Light Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
cambalinho 142 Practically a Posting Shark
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
cambalinho 142 Practically a Posting Shark
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
cambalinho 142 Practically a Posting Shark
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
cambalinho 142 Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.