Question
we implemented friend nonmember functions for a class and highlighted the benefits and drawbacks of nonmember functions. Consider the following class skeleton: // A rectangle
we implemented friend nonmember functions for a class and highlighted the benefits and drawbacks of nonmember functions. Consider the following class skeleton: // A rectangle object with a width and height class Rectangle public: // Constructs a rectangle with the given dimensions Rectangle(float width, float height) : w_(width), h_(height) {} private: // Private fields for width and height of the rectangle float w_, h_; }; // class Rectangle For each of the following functions, decide if, stylistically, they should be implemented as a member, nonmember, or friend nonmember function of the class. 1. operator
3. operator= that sets the dimensions of the Rectangle on the left-hand side of the operator to the dimensions of the Rectangle on the right-hand side. member nonmember friend nonmember Briefly explain your reasoning for the above responses:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started