가능한 중복 :
Why is it an error to use an empty set of brackets to call a constructor with no arguments?C++ 상속 오류
나는 작은 코드 샘플이 : 나는 변경하는 경우에는
#include <iostream>
using namespace std;
class A
{
public:
void print()
{
cout << "Hello" << endl;
}
};
class B: public A
{
public:
B() { cout << "Creating B" << endl;}
};
int main()
{
B b();
b.print(); // error: request for member ‘print’ in ‘b’, which is of non-class type ‘B()()’
}
을 아래 하나, 작동하는 경우
B* b = new B();
b->print();
스택에 개체를 할당 할 때 왜 작동하지 않습니까?