Hello world!
- 第一类,也是最常见到的写法。
#include <stdio.h> int main() { printf("Hello world!"); return 0; }#include <stdio.h> int main() { puts("Hello world!"); return 0; }#include <iostream> int main() { std :: cout << "Hello world!"; return 0; } - 用宏定义实现的输出字符串。
#include <stdio.h> #define say(sth) puts(#sth) int main() { return say(Hello world!); } - 退出时执行函数atexit()。
#include <stdio.h> void say(){ printf("world!"); } void sth(){ printf("Hello "); } int main(){ return atexit(say),atexit(sth); } - 在C++类里面实现。
#include <iostream> #include <cstddef> class secret{ private: virtual void say(){ std::cout << "Hello world!"; } }; int main(){ secret word; (reinterpret_cast<void (*)()>(**(intptr_t**)(&word)))(); return 0; } - 模版演示Hello world!。
#include <iostream> template <char * words> class say{ public: void operator ()(){ std::cout << words; } }; char hello[] = "Hello world!"; int main(){ return say<hello>()(),0; } - 使用C++类的构造函数和析构函数来实输出Hello world!。
#include <iostream> class say{ public: say(){ std::cout << "Hell"; } ~say(){ std::cout << "world!"; } }hello; int main(){ std::cout << "o "; return 0; }

被折叠的 条评论
为什么被折叠?



