Question: Question 6 (a) Briefly explain the differences between public, private and protected access modifiers? Give two reasons why you would use the private access modifier

 Question 6 (a) Briefly explain the differences between public, private and

Question 6 (a) Briefly explain the differences between public, private and protected access modifiers? Give two reasons why you would use the private access modifier with class state variables. [4 marks] (b) A class named Double has a single double type variable value, a constructor that takes one parameter as an input to initialise the variable, and two func- tions to obtain the integral and fractional parts of value as double type values. Write only the C++ declaration for the class with appropriate modifiers and access controls. [4 marks] (c) You have a class called Book and want to maintain a counter that keeps track of all of the books that have ever been created. What C++ code would need to be added to the class to do this? [2 marks] Total for Question 6: 10 marks]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!