I want to overload the =operator. It should work like that:
MyClass a;
double b=a;
How can I do that?
Tschüss, Andre
I want to overload the =operator. It should work like that:
MyClass a;
double b=a;
How can I do that?
Tschüss, Andre
 
    
    That's not operator= (assignment). It's an initialiser. You would normally do something like this by providing a constructor that takes MyClass as an argument - however, you can't do that for double. Instead, you need to provide a conversion function for MyClass:
class MyClass
{
  public:
    operator double() const { return 5.0; }
};
