error C2664: 'strcpy' : cannot convert parameter 1 from 'class std::basic_ 5
错误errorC2664:'strcpy':cannotconvertparameter1from'classstd::basic_string<char,structs...
错误error C2664: 'strcpy' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
程序:
#include "iostream"
#include "string"
using namespace std;
struct consumer
{string name;
int phonenumber;
double fee;
};
void creatconsumer(consumer **p)
{*p=new consumer;
strcpy((*p)->name,"Tom");
(*p)->phonenumber=123456;
(*p)->fee=6899.6;
cout<<"顾客姓名:"<<(*p)->name<<"电话号码:"<<(*p)->phonenumber<<"花费:"<<(*p)->fee;}
void main()
{
consumer *q=NULL;
creatconsumer(&q);
cout<<"顾客姓名:"<<q->name<<"电话号码:"<<q->phonenumber<<"花费:"<<q->fee;}
大神们帮忙看一下,貌似是string的问题,但是不太清楚。麻烦说的详细一点。 展开
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
程序:
#include "iostream"
#include "string"
using namespace std;
struct consumer
{string name;
int phonenumber;
double fee;
};
void creatconsumer(consumer **p)
{*p=new consumer;
strcpy((*p)->name,"Tom");
(*p)->phonenumber=123456;
(*p)->fee=6899.6;
cout<<"顾客姓名:"<<(*p)->name<<"电话号码:"<<(*p)->phonenumber<<"花费:"<<(*p)->fee;}
void main()
{
consumer *q=NULL;
creatconsumer(&q);
cout<<"顾客姓名:"<<q->name<<"电话号码:"<<q->phonenumber<<"花费:"<<q->fee;}
大神们帮忙看一下,貌似是string的问题,但是不太清楚。麻烦说的详细一点。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询