Abd*_*996 -2 c c++ program-entry-point
我遇到了一件有趣的事情.在一次采访中,我被要求将"Hello World"打印到控制台.但主要功能必须是:
int main(void)
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它一定不能修改!
class TEST{
public:
TEST(){
cout << "Hello World";
}
};
TEST test_obj; //Create an instnace to TEST Class
int main(){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这适用于C或C++(当然,在任何一种语言中都是非常糟糕的风格):
#include <stdio.h>
#define return puts("Hello World");
int main(void) {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
宏定义中的分号是必要的.它导致以下0;是一个语句表达式,它什么都不做.(在C++中main隐含return 0;了一个隐含的结尾,而在C中以C99开头.)
| 归档时间: |
|
| 查看次数: |
299 次 |
| 最近记录: |