为什么我的代码中会出现此错误?

use*_*362 0 c++

我的编译器在此代码中给出了"无法找到'ostream :: write(S1,int)'的匹配项"的错误.编译器发出错误的部分被注释

#include<iostream.h>
#include<stdlib.h>
int main()
{
    struct S1
    {
        char*str;
        S1*ptr;
    };

    S1 arr[]={" Aanna ",arr+1," Neha ",arr+2," Simran ",arr};

    S1*p[3];
    for(int i=0;i<3;++i)
        p[i]=arr[i].ptr;

    cout.write(p[0]->str,7).put('\n');
    cout.write((*p)->str,7).put('\n');
    cout.write(**p,7).put('\n');//why doesn't it work
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

M.M*_*M.M 6

**p有类型S1.没有重载版本ostream::write知道S1,所以你得到一个错误.

我会站出来猜猜你打算放 p[0]->ptr->str