为什么我不能使用cout在C++中打印字符串值数组?

Jor*_*ndo 4 c++ arrays cout

这是我写的一个非常简单的程序的代码片段.我对C++很新,但有Java背景,所以我可能对打印值如何工作有先入之见.我的问题是当我这样做时:

cout << "Please enter the weight for edge " << verticies[i] << endl;
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,指出操作数与<<的指定运算符不匹配.基本上它是说我不能做cout << verticies [i].

为什么会这样?

这是代码:

#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    string verticies[6] = { "AB", "AC", "AD", "BC", "BD", "CD" };
    int edges[6];

    for (int i = 0; i < 6; i++)
    {
        cout << "Please enter the weight for edge " << verticies[i] << endl;
    }

    system("PAUSE");

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

Ryp*_*Ryp 10

尝试包括<string>,应该就够了