Type of activation operator



  • How do you write the accent operator User type What would be the non-retroactivity of the types? I mean, like, operator double() etc.



  • The accusators of accustomed to any type write the same, whether it's a user or not.

    #include <iostream>
    

    struct A { int x; };

    struct B {
    operator A() {
    A a = {1};
    return a;
    }
    };

    int main() {
    A a;
    B b;
    a = b;
    std::cout << a.x << '\n';
    }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2