今天,当我阅读C++ Primer时,它说类初始化器不能使用我在Stackoverflow and find a similar question here.And上搜索的()。公认的答案是:原因可能是成员函数的声明与.But类型成员的定义之间存在歧义,我不完全同意他的观点。我尝试了下面的代码:
struct Sales_data
{
int i(5); //this line can't be regard as a function
};
但是编译器仍然可以complain.Who告诉我为什么。\ compiler:clang++版本:3-4
发布于 2015-04-04 13:29:38
这种语言是不允许的。原因是,在某些情况下,它无法从函数声明中消除歧义:
struct foo
{
int bar();
};
因此,它不是通过允许()
有时工作来复制整个()
的惨败,而是完全不允许的。
https://stackoverflow.com/questions/29447003
复制相似问题