#include <iostream>
class A {
public:
A (){
std::cout << "construction!" << std::endl;
}
A (const A&) {
std::cout << "copy construction!" << std::endl;
}
A (A&&) {
std::cout << "move construction!" << std::endl;
}
A& operator=(A&&) {
std::cout << "move copy operator!" << std::endl;
return *this;
}
~A() = default;
};
A makeA () {
return A();
}
void func (A&& a) {
std::cout << "func(A&&)" << std::endl;
}
void func (const A& a) {
std::cout << "func(const A&)" << std::endl;
}
// void func (A a) {
// std::cout << "func(A)" << std::endl;
// }
int main () {
A a(makeA());
// A a(std::move(makeA()));
//func(makeA());
//func(std::move(makeA()));
return 0;
}
// 打印结果为:construction!
现在的问题是 A a(makeA())会进入哪个构造函数?