请问大家一个非常简单的C++问题

来源:百度知道 编辑:UC知道 时间:2024/05/06 00:14:15
#include<iostream>
using namespace std;

class Test{
public:
string str[5];
Test(){
cout << str[0] << endl;
}
};

int main(){
Test t;
return 0;
}
怎么编译有误呢?
是string那里出了问题:)我是用的Visual C++啊,谢谢各位了,但是我在看的C++编程思想上的这个类型

同志们,只要在上面加个#include<string>就OKAY了,谢谢各位

#include "string.h"
没有这个头文件,哪里来的string类型

你用的是什么编译器?
string str[5]好象没有这种类型吧?
可以试试char str[5].

貌似是string 出的问题

class Test{
public:
string str;
Test(){
cout << str[0] << endl;
}
};

int main(){
Test t;
return 0;
}

或者

class Test{
public:
char str[5];
Test(){
cout << str[0] << endl;
}
};

int main(){
Test t;
return 0;
}