I see a function member in a c++ class:
class bar{
//..
}
class foo{
public:
foo(){};
//...
operator bar(){
return bar();
}
}
it's not an operator overloading, can anyone explain it to me ?
I see a function member in a c++ class:
class bar{
//..
}
class foo{
public:
foo(){};
//...
operator bar(){
return bar();
}
}
it's not an operator overloading, can anyone explain it to me ?
It is a user-defined conversion operator which constructs a bar
object from the foo
object. The purpose is to enable type casting from foo
to bar
.