Say "Hello, World!" With C++
Say "Hello, World!" With C++
+ 32 comments -Don't use 'printf' here, it's a C function. C++ is not C in any way. Use 'std::cout' instead.
-Never use 'using namespace std'. This directive has been added for compatibility purpose and can lead into multiple definitions in larger projects. It breaks the namespace principle. However, you can use it for literals (e.g. 'using namespace std::chrono_literals'). If you really don't want to use the 'std::' prefix, you can use 'using std::cout', 'using std::endl' and so on for each function, class, etc. you want to import in the global namespace.
#include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }
And with 'using':
#include <iostream> using std::cout; using std::endl; int main() { cout << "Hello, World!" << endl; return 0; }
+ 4 comments Weirdest challenge. All I had to do was submit it with no change and it passed.... whatever.
+ 0 comments Here's my implementation
int main() { int out[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x2C, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; for (int i = 0; i < 12; i++) { char put = static_cast<char>(out[i]); std::cout << put; } return 0; }
+ 6 comments #include <iostream> using std::cout; template <typename T> T print(void){ return "Hello, World!"; } int main() { cout << print<const char *>(); return 0; }
+ 0 comments At that point, you'll infrequently go over a venture where a craftsman has made their own deck dependent on a most loved being a fan. Sadly, they're Geeky Deck not liable to be printed because of copyright reasons. I did a touch of burrowing to locate some great decks that you may get a kick out of the chance to have in your own assortment.
Sort 2757 Discussions, By:
Please Login in order to post a comment