代码如下
class A {};
class B
{
public:
B(const A& a) {}
void fun() {}
};
int main(int argc, char *argv[])
{
B b(A());
b.fun(); // Error: left of '.fun' must have class/struct/union
A a;
B b2(a);
b2.fun(); //Okay
return 0;
}
为什么?