Can anyone explain what this code does?
Con(const char* n){
char_number = new char[sizeof(n) 1];
string(n).copy(char_number, sizeof(n) 1);
}
I don't understand the string(n)
part. What exactly does this do?
CodePudding user response:
From the documentation:
std::string::string
copy constructor
Constructs a copy of str.
string (const string& str);
from c-string
Copies the null-terminated character sequence (C-string) pointed by s.
string (const char* s);
Note: .copy()
is explained here.