我的計算機科學教授希望我們找到cout
的聲明。我使用g ++和-E參數編譯了一個簡單的Hello World程序。這裏是我的HELLO.CPP是什麼樣子:cout在哪裏申報?
#include <iostream>
using namespace std;
int main(){
string name="";
cout << "Good morning! What's your name?";
cin >> name;
cout << "Hello " << name << ".\n";
return 0;
}
我的編譯命令:
g++ -E hello.cpp > hello.p
在hello.p,我在VIM跑了搜索,像這樣:
:/cout
我請參閱以下行:
extern ostream cout;
那是t他聲明cout
,並且cout
是ostream
類的一個實例?
編輯:
什麼是wcout
聲明那裏?如果我正確地記得字母「w」代表「寬」,但我不知道有什麼含義。什麼是wcout
和wostream
?
我會願意猜測代碼中的某處,當您鏈接到IOStream時,會在您的可執行文件中找到該代碼。 – Kaslai 2012-03-11 04:16:28
@Aslai - 我已經從該代碼中抽出一行。我想知道是否就是這樣。 – Moshe 2012-03-11 04:18:24
試試這個:http://www.cplusplus.com/ - 在搜索框中鍵入'cout'。 – 2012-03-11 04:28:46