<分区>
为什么以下不编译:
typedef int Table;
class FullObjId
{
public:
explicit FullObjId( const Table* i ) {}
};
class TableInfo
{
public:
TableInfo( const FullObjId& o ) {}
bool isValid() { return true; }
};
void dataSourceForHist( const Table& table )
{
// The next line gives an error
TableInfo tableInfo( FullObjId( &table ) );
// Unless it's written like this:
//TableInfo tableInfo( ( FullObjId( &table ) ) );
if (!tableInfo.isValid())
{
...
}
}
我已尝试使用适用于 Linux 的英特尔编译器 12.1,并使用 http://gcc.godbolt.org/使用 g++ 4.8、icc 13.0、clang 3.4.1。 我尝试过的所有编译器都给出如下错误:
error: request for member ‘isValid’ in ‘tableInfo’, which is of non-class type ‘TableInfo(FullObjId&)’