L
leonkatz
What operators do I have to overload to be able to do a strcpy(pStr,
myObj) ?
Example:
class MyClass {
public:
MyClass(char* pStr){
if(pStr == NULL) {
str = NULL;
} else {
const int len = strlen(pStr);
str = (char*)malloc(len);
strcpy(str, pStr);
}
};
int GetStrLen() {
return strlen(str);
}
char* str;
}
void main()
{
MyClass1 mc("this is a test");
const int size = mc.GetStrLen();
char *pStr = new char[size];
// I do not want to change this line !!
// Change should be made in the class
strcpy(pStr, mc);
}
myObj) ?
Example:
class MyClass {
public:
MyClass(char* pStr){
if(pStr == NULL) {
str = NULL;
} else {
const int len = strlen(pStr);
str = (char*)malloc(len);
strcpy(str, pStr);
}
};
int GetStrLen() {
return strlen(str);
}
char* str;
}
void main()
{
MyClass1 mc("this is a test");
const int size = mc.GetStrLen();
char *pStr = new char[size];
// I do not want to change this line !!
// Change should be made in the class
strcpy(pStr, mc);
}