C++裡有兩種#include. 一種是新的#include, 尾端並無.h. 這種#include檔裡所有的函式和變數都被分類在std這個分類裡. 所以要用這種#include檔裡所有的函式和變數你要考慮到namespace.
#include <iostream>
int main()
{
    std::cout << hello;
    return(0);
}

#include <iostream>
using namespace std;
int main()
{
    cout << hello;
    return(0);
}
using namespace std;這句是告訴C++你要用std這分類裡的函式及變數. 所以C++當在找尋一個函式或變數的定義時會到std這個分類區裡找.因此你在用std這分類裡的函式及變數時不用打入std::<函式/變數名>
arrow
arrow
    全站熱搜

    天才R 發表在 痞客邦 留言(0) 人氣()