typedef struct a
{
int i;
         int      j;
}a1;typedef enum b
{
std::string  str1;
         std::string  str2;
}b1函数
void inttostr(const a my_a, b & my_str);
{.....}//高手写的,完全正确我现在定义一个变量
a my_a; 并获得my_a内部的数据,
那么我如何通过函数inttostr(const a my_a, b & my_str)得到my_str,谢谢,我用如下方法错误:
b & my_str;
inttostr(my_a,&my_str);
错误提示为:my_str没有初始化;不能将参数my_a转化为my_str,
上面因该是我使用错误,请帮忙,谢谢

解决方案 »

  1.   

    上面有错,把struce 写成enum正确如下:typedef struct a
    {
    int i;
             int      j;
    }a1;typedef string b
    {
    std::string  str1;
             std::string  str2;
    }b1函数
    void inttostr(const a my_a, b & my_str);
    {.....}//高手写的,完全正确我现在定义一个变量
    a my_a; 并获得my_a内部的数据,
    那么我如何通过函数inttostr(const a my_a, b & my_str)得到my_str,谢谢,我用如下方法错误:
    b & my_str;
    inttostr(my_a,&my_str);
    错误提示为:my_str没有初始化;不能将参数my_a转化为my_str,
    上面因该是我使用错误,请帮忙,谢谢
      

  2.   

    b & my_str;
    inttostr(my_a,&my_str);
    =>
    b my_str;
    inttostr(my_a,my_str);
      

  3.   

    提示不能将参数my_a转化为my_str
      

  4.   

    这样肯定不行,
    应该是
    a my_a;
    b my_str;
    inttostr(my_a, &my_str);