目次 |
---|
・cygwinでc++ ・c++の名前空間 |
g++ hello.cppとします。以下、hello.cppのサンプルです。
#include <iostream> int main{ std::cout << "hello" << std::endl; return 0; }coutの前のstdは名前空間と呼ばれる機能で、他のモジュールとの衝突を避けるため、coutはstdというモジュールの名前空間になります。
using namespace 名前空間とします。上記のサンプルに名前空間を指定した場合は以下のようになります。
#include <iostream> using namespace std; int main{ cout << "hello" << std::endl; return 0; }