Question: solve these problems: What type of parameter should be used when the function's implementation does change the value of a parameter and you want the
solve these problems:










What type of parameter should be used when the function's implementation does change the value of a parameter and you want the change to alter the actual argument? Reference parameter Value parameter Const reference parameter Void parameter If you are implementing a class and you want to write a non-member function that needs access to the class's private members, what would you do? Make the function a member function Declare the variables of the class as public Declare the non-member function as a friend of the class It is not possible for a non-member function to access the class's private members A member function that can change the value of an object, or in other words, change the value of its private variables, is called Modification member function Friend function Public function Constant member function A member function that may examine the status of its object (i.e., access its private variables) but it is forbidden from changing the object Modification member function Friend function Public function Constant member function A special type of member function that is called automatically whenever an object of the class is declared. It must have the same name as the class and no return data type, not even void. Constant member function Constructor Friend function Inline member function Here is the start of a class declaration: class foo \{ public: void x (foo f); void y( const foo f); void z( foo f) const; Which of the three member functions can alter the PRIVATE member variables of the foo object that activates the function? Only x can alter the private member variables of the object that activates the function. Only y can alter the private member variables of the object that activates the function. Only z can alter the private member variables of the object that activates the function. Two of the functions can alter the private member variables of the object that activates the function. All of the functions can alter the private member variables of the object that activates the function. What is the common pattern of class definitions that is used in Chapter 2? Member functions and member variables are both private. Member functions are private, and member variables are public. Member functions are public, and member variables are private. Member functions and member variables are both public. Consider this class definition: class quiz \{ public: quiz ( ); int f(r); int g ( ) const; private: double score; \} ; Which functions can perform or carry out the following assignment to the private member variable score? score=1.0; Both f and g can carry out the assignment. f can carry out the assignment, but not g. g can carry out the assignment, but not f. Neither f nor g can carry out the assignment. double score; \} Write the implementation of the overloaded addition operator for the class Quiz (notice it has been declared as a friend function already). Adding two Quiz objects means you assign the average of their scores to the new object's score Write a main program where you: Create a Quiz object called cs 246 quiz1 with a score of 80 Create a Quiz object called cs246 quiz2 with a score of 50 Create a Quiz object called cs 246quiz3 and assign to it the result of adding the previous 2 objects (cs246quiz1 and cs246quiz2) Display the score of cs246quiz3 to screen A function that has its entire implementation given right in the class definition Member function Inline member function Constructor Default Constructor
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
