我有一小段代码有一个声明 void();
int main()
{
void( ); // 1: parses fine in GCC 5.4.0 -Wpedantic
// void; // 2: error declaration does not declare anything
}
Run Code Online (Sandbox Code Playgroud)
什么是1 void()
?
是什么让1 void()
与2不同void;
?
我已经读过了:
但我很好奇松散的声明是否为void(); 不同于其中之一(当然为什么)
这个程序如何编译好?
int main() {
void(); // Does this create a "void" object here?
}
Run Code Online (Sandbox Code Playgroud)
我已经在MSVC和GCC下进行了测试.但这void
是一个不完整的类型.对任何其他不完整的用户定义类型执行相同操作时,
class Incomplete;
int main() {
Incomplete(); // Error saying "Incomplete" is incomplete.
}
Run Code Online (Sandbox Code Playgroud)