Question OOP-CTOR-0062
HardWhat is the output of this code?
#include <iostream>
#include <utility>
using namespace std;
class P {
public:
P() { cout << "d "; }
P(const P&) { cout << "c "; }
P(P&&) noexcept { cout << "m "; }
P& operator=(const P&) { cout << "ca "; return *this; }
P& operator=(P&&) noexcept { cout << "ma "; return *this; }
};
int main() {
P a;
P b = a;
P c = std::move(a);
b = c;
c = P();
}
- A.
d c m ca d ma
- B.
d c c ca d ca
- C.
Sign up free to see the answer and a step-by-step explanation.