Dav*_*Lin 7 c++ llvm clang copy-constructor
为什么以下程序的输出只是int3
和不int3&4
?
#include <iostream>
class B
{
public:
explicit B(int i) { std::cout<<"int"<<i; }
B(const B& rhs, int i = 0) { std::cout<<"&"<<i; }
};
int main(int, char**)
{
B b(B(3), 4);
}
Run Code Online (Sandbox Code Playgroud)
命令: clang++ test.cpp -O0
编译器:Apple clang 3.0版(标签/ Apple/clang-211.12)(基于LLVM 3.0svn)