2014-02-27 46 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

相关问题