C++ Hello World

From D3xt3r01.tk
Jump to navigationJump to search

YEY

So I decided to give OOP (Object Orientated Programming ) a chance. So I started from scratch with C++

Code

#include <iostream>

using namespace std;

int main (void){
        cout << "Hello world" << endl;
        return 0;
}

Compile in linux with

 g++ file.cpp -o helloworld

and run

 ./helloworld

would output

 Hello world

More details

The #include <iostream> means include the "input output stream" library which gives us access to the 'cout' function. The namespace thingy is a lil bit more complicated. int main(void) means we're creating the main function with no parameters which will return an integer value ( notice the return 0 ). Cout is the function that outputs hello world on the screen and endl adds a endline character.