c ++试图将字符串输入传递给二维矩阵

c++ trying to pipe string input to 2dmatrix

我的源代码如下:

string** field = new string*[m]; //initialise a mxn Matrix=> field.
for (int i = 0; i < m; i++) { // we do this because the compiler does not know the ammount of memory required in advance hence use of poitners. 
    field[i] = new string[n]; 
}

for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
        cin >> &field[i][j];
    }
}

我在尝试将输入从 cin 推送到我的二维矩阵字段时遇到问题。我试过双重取消引用,即。 &&字段,但仍然得到相同的错误。任何帮助将不胜感激。

我最初写的是 cin >> field[i][j],但我很困惑,因为智能感知说没有运算符匹配 std::istream 和 std::string 类型的操作数。为了解决这个问题,我不得不导入字符串更正后的代码如下:

    #include <string>;

//...
    string** field = new string*[m]; //initialise a mxn Matrix=> field.
    for (int i = 0; i < m; i++) { // we do this because the compiler does not know the ammount of memory required in advance hence use of poitners. 
        field[i] = new string[n]; 
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            cin >> field[i][j];
        }
    }