2016-12-04 141 views
-1

我目前正在努力學習C++的基礎知識。我使用視覺工作室,並發現了一個奇怪的問題:visual studios cout << not working

#include "stdafx.h" 
#include <iostream> 

using namespace std; 


int main() 
{ 
    string name = "Example name"; 
    cout << "Hello " << name << endl; 

    int pause; 
    cin >> pause; 
    return 0; 
} 

試圖輸出我的字符串時,我不能使用「< <」的兩倍。它顯示第二個< <下的紅線,並不會讓我編譯。任何答案?我應該只使用另一個IDE嗎?

+2

定義添加的#include''哦 – wally

回答

2

你忘了#include <string>其中operator<<std::string

+0

,OK。我在看的教程沒有提到這一點。謝謝! :-) –

相關問題