I have modified the copy constructor as constant in order to fix the compilation error.Again the compiler throws an error,because calling a non-const method from a const method.
Error:
String.c: In copy constructor 'String::String(const String&)':
String.c:49: error: passing 'const String' as 'this' argument of 'int String::length()' discards qualifiers
String.c:51: error: passing 'const String' as 'this' argument of 'String::operator char*()' discards qualifiers
String.c:51: error: invalid conversion from 'char*' to 'const char*'
String.c:51: error: initializing argument 2 of 'char* strcpy(char*, const char*)'
make: *** [all] Error
Please check an dhelp me to resolve the issue ..
Thanks for looking into this
You define a cast at line 21 which returns a char *, which is mutable.
This is what is being passed to strcpy. This violates the const declaration of the parameter. You need to define a second cast.