<<< Updated constructors | Index | Using named rectangles >>> |
Besides naming the rectangle when we create it, we also want to copy rectangles and rename them any way we want.
Thus, new member functions provide read/write access to the object's name:
struct Rectangle { int width; // member variable int height; // member variable char const* ptr_name; //... void set_name( char const* ptr_name_ ) { ptr_name = ptr_name_; } char const* get_name() const { return ptr_name; } //... };//struct Rectangle
Since get_name() makes no changes in the object's state, it is declared const.
<<< Updated constructors | Index | Using named rectangles >>> |