- 6

What is the keyword for overloading an operator in C++?

What is the keyword for overloading an operator in C++? Quis Module C++

3rd Feb 2021, 6:18 AM
HENDRA WIJAYA ANJAS HARIANJA
HENDRA WIJAYA ANJAS HARIANJA - avatar
3 odpowiedzi
+ 1
Syntax (example of + overloading): className operator+(className &obj) { } className operator<op>(className &obj) { } I think the answer is already in your question. Please review your lessons if you are confused, or you can just check the comment sections in that quiz to get help from the community in that course, way easier.
3rd Feb 2021, 6:25 AM
noteve
noteve - avatar
+ 1
You just have to write operator@ (where @ is the operator you want to overload) as name of the overloading function
3rd Feb 2021, 6:26 AM
Angelo
Angelo - avatar
+ 1
Here's a complete example by John Wells sir. Includes links to examples in other languages. https://code.sololearn.com/cStdw0OPtPxG/?ref=app
3rd Feb 2021, 7:49 AM
Ipang