Strange overloaded operator

I'm currently applying for my first job for software development. Specificly C++ in this case. The application manager send me a rather simple class, in which I had to define all the parts to my knowledge!

I pretty much got everything, except one strange line, which bothers me more than it should:
1
2
/* I actually don't know. */
operator RPT() const;


As can be seen, I don't really know what exactly that statement does.
I'm well aware of operator overloading like operator+=(.., ..).
Last edited on
Hey, good luck!

It looks like a user-defined implicit type conversion from the type of *this to RPT, which is presumably a type name. For example, the_answer_t can implicitly be converted to int:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

struct the_answer_t { 
  operator int() const { return 42; }
};

void print(int x) { std::cout << x << "\n"; } 

constexpr the_answer_t the_answer;
int main() { print(the_answer); }


http://coliru.stacked-crooked.com/a/6e1cd4d8a49b41e3

See: https://en.cppreference.com/w/cpp/language/cast_operator
Last edited on
Topic archived. No new replies allowed.