| <<< A named rectangle | Index | Updated constructors >>> |
A new member variable ptr_name holds the pointer to a string of characters in memory:
struct Rectangle {
int width; // member variable
int height; // member variable
char const* ptr_name;
//...
};//struct Rectangle
Recall that char* pointer stores the address of the first character of the string.
Similarly, char const* is the pointer to a constant character, telling the compiler to disallow any modifications to the characters via this pointer.
Thus, the exact type of ptr_name is a pointer to const char -- well suitable for a string of characters allocated elsewhere, outside of the scope of the Rectangle struct
| <<< A named rectangle | Index | Updated constructors >>> |