I'm quite new to c++ and I was wondering what this was doing in this code here:
class MyString
{
private:
char* buffer;
public:
MyString(const char* initString){
buffer = NULL;
cout << "Default constructor: creating new MyString" << endl;
if(initString != NULL)
{
buffer = new char [strlen(initString)+1];
strcpy(buffer, initString);
cout << "buffer points to 0x" << hex;
cout << (unsigned int*)buffer << endl;//<---- here the (unsigned int*)
}
}
};
int main(){
MyString sayHello("Yo guys");
return 0;
}
why do I have to force re-assign a new pointer poiting to an unsigned int for the buffer with (unsigned int*) knowing its already been assigned a pointer of chars, I don't understand, is it because the strcpy transforms the type or it is something else?. Thanks in advance.