结构体中用 string 如何代替 char name [20]

结构体中用 string 怎么代替 char name [20]
# include 〈iostream〉
# include 〈string〉
# include 〈cstring〉

using namespace std;

struct xinx

  //  string name;               //error
        char name[20];       //ok
        int sex;
};

int main()
{ 
      xinx * st =  new xinx[5];

     return 0;



如果用string 应该怎么定义?
------解决方案--------------------
明明是可以用的,为什么大家都说不行,我表示理解不能,代码如下:

#include <iostream>
#include <string>

struct xinx
{
std::string name;
int sex;
};

int main()
{
xinx * st =  new xinx[5];

return 0;
}


------解决方案--------------------
引用:
明明是可以用的,为什么大家都说不行,我表示理解不能,代码如下:

#include <iostream>
#include <string>

struct xinx
{
std::string name;
int sex;
};

int main()
{
xinx * st =  new xinx[5];

return 0;
}


楼主的代码在我这里没报错,用的vc6.0,struct里边定义了一个string对象,可以用的