assignment operator overloading skipped / not happening

前端 未结 3 1497
别那么骄傲
别那么骄傲 2021-01-25 06:22

I\'m trying to create a library for some work and am using operator overloading for assignment operation. Supposed X and Y are two instances of the class that has = overloaded t

3条回答
  •  没有蜡笔的小新
    2021-01-25 07:13

    What's going on is that,

    A p = q + r;
    

    Calls the copy constructor of A, not the assignment operator. Yes, it's weird. It's the same as if you had typed this:

    A p(q + r);
    

提交回复
热议问题