Is there a way to extend a data type in C++, like you can in JavaScript?
I would imagine this is kind of like this:
char data[]="hello there";
char& capitalize(char&)
{
//Capitalize the first letter. I know that there
//is another way such as a for loop and subtract
//whatever to change the keycode but I specifically
//don't want to do it that way. I want there
//to be a method like appearance.
}
printf("%s", data.capitalize());
This should somehow print.
The closest you can get is using operator overloading, e.g.
Alternative approaches include creating a class with
operator std::stringoverloaded and a constructor to initialize it using anstd::string.