关于字符串替换问题~~ 求助
字符串的替换问题 ~~ 求助 帮忙改下!#include <iostream.h>
#include <string.h>
class String
{
public:
String(){p=NULL;}
~String(){}
String(char *str);
strcpy (String &string1,String &string2);
void display();
private:
char *p;
};
String::String(char *str)
{
p=str;
}
void String::display ()
{
cout<<p;
}
String::strcpy (String &string1,String &string2)
{
cout<<strcpy(string1,string2);
}
int main()
{
String string1("China"),string2("Amercia"),string3("Book"),string4("China");
char *p=strcpy(string1,string2);
return 0;
}
结果显示
error C2664: 'strcpy' : cannot convert parameter 1 from 'class String' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
要求用到类~~~~ 怎么改正啊??