实例化类时 会出现两种情况 如下 :
有括号 无法使用 最后一个注释内的语句
无括号 则能用
error: request for member 'Person:: func' in 'man', which is of non-class type 'Man()'
#include <iostream>
using namespace std;
class Person
{
public:
void func()
{
cout << "base func" << endl;
}
};
class Man: public Person
{
public:
void func()
{
cout << "deperive func" << endl;
}
};
int main()
{
Man man();
cout << "man.Person::func()显示调用的输出是:";
/**********************************************/
//man.Person::func();
/*********************************************/
system ( "pause" );
}
有无括号的区别是什么 网上我并没有找到我认为合理的答案
Man man();
is considered a function declaration...
A function named man has a return type of Man