小编Ziv*_*ion的帖子

C++ 在类中使用 iostream

我正在使用iostreammap。当我尝试设置函数时,它们会抛出错误。

我的代码:

#include "string"
#include "iostream"
#include "map"

using namespace std;

class myClass {
    map<string, string> Map;
    Map["Ziv"] = "Sion";

    cout << Map["Ziv"];
};
Run Code Online (Sandbox Code Playgroud)

我的错误:

error: 'Map' does not name a type
error: 'cout' does not name a type
Run Code Online (Sandbox Code Playgroud)

为什么我不能使用iostreamand cout

c++ dictionary cout class

-10
推荐指数
1
解决办法
266
查看次数

标签 统计

c++ ×1

class ×1

cout ×1

dictionary ×1