c++ - 在 C++ 中出现此错误, "no match for ' operator>>' in ' std :cin. std

标签 c++

#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++ 的新手,在我的基础计算机编程课上,我们必须制作一些可以计算体积的东西,有人可以帮我解决这个错误吗?

最佳答案

您不能从 cin 提取到 endl - 这没有任何意义。您将 endl 与输出流一起使用以插入换行符并刷新流。只需删除 >> endl

此外,您拼错了 length

关于c++ - 在 C++ 中出现此错误, "no match for ' operator>>' in ' std :cin. std,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22081563/

相关文章:

在抽象类中找不到 C++ 标识符

c++ - 在 LGPL 下的商业产品中使用 Qt 时如何允许私有(private)修改

c++ - 如何确保 mount 命令在 qt 进程中实际完成

c++ - 使用 Boost 时的内存泄漏检测

c++ - 有问题的代码???我的析构函数有问题吗?

C++11 只允许继承某些类

c++ - 哪个有更好的内存访问? (C++)

c++ - 使用类包装器对对象进行线程安全访问是否符合 C++11?

c++ - 从其他函数调用 WinMain

c++ - 如何检查 SQLite 数据库是否在 C/C++ 中打开