C++#001_Hello World!

C++を勉強するメモです。


IDE インストール

http://www.codeblocks.org/downloads/26

mingw-setup.exeをダウンロード。

インストール終わったらNew>Empty fileします。

Save file。

拡張子は.cpp忘れずに。

Hello World

#include <iostream>
using namespace std;

int main(){

    cout << “Hello World!\n”;
    cout << “testing 2” << endl;
    cout << “Hey hello again” << endl;
    return 0;

}

解説

#include <iostream>
using namespace std;

int main(){

    cout << “Hello World!\n”;
    cout << “testing 2” << endl;
    cout << “Hey hello again” << endl;
    return 0;

}

Line 1: #include <iostream>はiostream Header Filesをプログラムの中に使えるように、例えばLine5にあるcout の機能。

Line 2: using namespace std はStand libraryからstd Objectや変数を使えるようになる。

Line 4: Function Callです。

Line 5: cout はTerminalから出力すると考えてよいでしょう。

Line 6: Main Functionからreturn 0 

シェアする

  • このエントリーをはてなブックマークに追加

フォローする