2301_80381957 2023-11-23 14:44 采纳率: 33.3%
浏览 82

显示没有与这些操作数匹配的<<运算符,加上string头文件了也#include <iostream,如何解决?

显示没有与这些操作数匹配的<<运算符,咋回事,加上string头文件了也

img

#include <iostream>
#include "rt.h"
#include <string>
using namespace std;
struct xuesheng
{
    int lk;
    string jh;
    int iu;
};
struct laoshi
{
    string po;
    int qw;
    int er;
    struct xuesheng mn[3];
    
};
void fuzhi(laoshi nm[], int poi)
{
    string mingzi = "abcd";
    for (int i = 0; i < poi; i++)
    {
        nm[i].po = "laoshi_";
        nm[i].po += mingzi[i];
        cout << "老师名字为: " << nm[i] << endl;

    }
}

int main()
{ 
    laoshi nm[3];
    {
            ("李老师", 3409, 22,
            "王老师", 3408, 40,
            "刘老师", 3407, 25);
    }; 
    int poi = sizeof(nm) / sizeof(0);

        system("pause");

    return 0;
}

  • 写回答

2条回答 默认 最新

  • threenewbee 2023-11-23 14:45
    关注

    cout << "老师名字为: " << nm[i] << endl;
    ->
    cout << "老师名字为: " << nm[i].po << endl;

    评论

报告相同问题?

问题事件

  • 创建了问题 11月23日