c++ - 错误:'std::cin 中的 'operator>>' 不匹配

标签 c++ compiler-errors

<分区>

我带着另一个可能是菜鸟的问题回来了。 xP

所以我现在有这个。

#include <iostream>

using namespace std;

int main()
{
    string input;

    int man;

    cout<<"Choose your Character- 1.Sven or 2.Macy: ";
    cin>>input;
    cin.ignore();

    if ( input == "Sven" ){
        cout<<"Welcome to CRPG, my good Sir!";
        return 0;
        cin>>"Sven starts his journey at the Forest of Despair. At the beginning of the path, a fork in the road sits in his way. Which path shall you take? L or R?";
    }

    else if ( input == "Macy" ){
        cout<<"Girls cant fight, go back: ";
    }
}

是的,我已经看到并阅读了有关同一问题的其他帖子,但似乎没有一个适用于我。那么有什么方法可以解决这个问题?

最佳答案

您必须包含 header <string>

#include <string>

此 header 包含 operator >> 的声明对于 std::string 类型的对象

也在这个声明中

   cin>>"Sven starts his journey at the Forest of Despair. At the beginning of the path, a fork in the road sits in his way. Which path shall you take? L or R?";

你打错了。应该有 cout <<而不是 cin >>

关于c++ - 错误:'std::cin 中的 'operator>>' 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25412015/

相关文章:

c++ - 返回相同值的随机数生成器(C++)

c++ - 添加大数字 C++ - 初始化程序失败

c# - C# 中是否有 List<T> 的方法,例如在 c++ 中为 vector<T> 调整大小

c++ - 我在哪里可以找到一个好的 boost 引用?

c# - 如何解决此 .Net 3.5 警告/错误?

java - 返回对象或 null 时缺少 return 语句

java - 在初始化之前通过 getter 访问最终字段

c++ - %mod 生成二项式系数的兼容方法

c# - 通过 CSharpCodeProvider 编译时出现编译器错误

c++ - BOOST图cc1plus : out of memory allocating