Declaring a + operator in C ++

I have a Samp class. In Samp.cpp, I can define / declare a function like

Samp& operator+(Samp& other) { std::cout << "something"; return other; } 

What is this function? What should I call it?

+6
source share
1 answer

This is actually unary + , you call it like this:

 Samp s; +s; // <-- here 
+11
source

Source: https://habr.com/ru/post/955713/


All Articles