nclude<iostream>
#include<assert.h>
using namespace std;
const char* &StringCopy( char* lpszDestination,const char* lpszSource )
{
assert((lpszSource!=NULL)&&(lpszDestination!=NULL));
while(lpszSource!=NULL)
{
* lpszDestination++ = *lpszSource++ ;
}
return lpszDestination;
}void main()
{
char *lpszDestination;
char *lpszSource="I am Wang Gang.";
StringCopy(lpszDestination,lpszSource);
cout << lpszDestination << endl;
}
编译时:“return”: 无法从“char *”转换为“const char *&”
#include<assert.h>
using namespace std;
const char* &StringCopy( char* lpszDestination,const char* lpszSource )
{
assert((lpszSource!=NULL)&&(lpszDestination!=NULL));
while(lpszSource!=NULL)
{
* lpszDestination++ = *lpszSource++ ;
}
return lpszDestination;
}void main()
{
char *lpszDestination;
char *lpszSource="I am Wang Gang.";
StringCopy(lpszDestination,lpszSource);
cout << lpszDestination << endl;
}
编译时:“return”: 无法从“char *”转换为“const char *&”