2014-02-27 52 views
0
#include <iostream> 

int main() 
{ 
    using std::cout; 
    using std::endl; 
    using std::cin; 
    short width; 
    short legnth; 
    short height; 
    short volume; 
    volume = (legnth * width * height); 

    cout << "This program will determine the volume of a cube" << endl; 
    cout << "Enter the legnth of the cube: "; 
    cin >> legnth >> endl; 
    cout << "Enter the width of the cube: "; 
    cin >> width >> endl; 
    cout << "Enter the height of the cube: "; 
    cout << "Your volume is: " << volume; 
    cout << "Press any key to exit :)"; 
    cin.get(); 

    return 0; 

我是C++的新手,在我的基本計算機編程課上,我們不得不做一些可以計算音量,有人可以請幫我修復這個錯誤在C++中得到這個錯誤,在'std:cin.std'中不能匹配'operator >>'

}

回答

0

std::endl用於輸出流而不用於輸入流。我認爲,如果對初學者有意義,因爲你可以把換行符(大多數情況下,如果你想從用戶那裏獲取輸入)輸入到輸入流中,但是std::endl根本不適用於std::cin

除了我相信你並不真的需要這樣做,因爲當你按下「Enter」鍵確認你輸入的換行符字符也被打印到輸出流。

+0

THANKYOU !!我的教授對我來說太快了!經過兩個小時的時間,他完成了所有他告訴我們要做的事情,然後我終於得到了他所覆蓋的所有材料的一個小組成員,但是我只是爲了這個錯誤而苦惱。我相信,如果教授實際上按照時間順序進行有效教學,我會知道std :: cin是如何工作的,但不幸的是,生活並不總是按照你想要的方式工作,哈哈。 – user3362546

6

不能提取cinendl - ?這沒有任何意義,您使用endl輸出流中插入新行並刷新只需刪除>> endl即可。

此外,你錯誤地拼寫了length

相關問題