Yet another of these cryptic 'it doesn't work' messages. When will you guys realize that its not mind-readers on the other side? What doesn't work? What are the error messages? Where is you program????
Line 27 in main. To use std::strcpy you should include <cstring> (maybe you want to use the my_cpy function instead?). #include <cstring>
Line 29 in main. malloc returns a void pointer so if you want to assign it to a char pointer you need to cast it. char* str = static_cast<char*>(malloc(10));
If you want to be able to pass a string literal to the String constructor you need to make the parameter type a pointer to a const char. You'll also need to change the condition for the case when a null pointer is passed in because you can't assign a non-const char* to a const char*.
After fixing the problems I pointed out the code compiles and seems to run just fine. If you still have problems you will have to tell us what they are. Do you get an error message? What is it? Is the output wrong? What do you get and what did you expect?
Error C2440 'initializing': cannot convert from 'void *' to 'char *' Line 56
Error C2440 'initializing': cannot convert from 'const char *' to 'String' Line 60