When you define a C++ class so that the result is an ADT, which of the following remarks about whether to make a member variable or function public or private are correct?

a. Make them all public. It simplifies life and makes things more efficient to be able access members anywhere.
b. Don’t make member variables public.
c. Make all member functions public.
d. There are some member functions that shouldn’t be public, but most should be public.


Probably b) is correct, see Explanations. d) is correct.
Explanation:
If you follow a) you are not encapsulating anything. You won’t have an ADT if you do this. b) is likely to be a good rule to follow. c) is too restrictive. There are helper functions, or as the text calls them, auxiliary functions that help member functions do their job that should not be public, but most member functions should be public, and member variables private.

Computer Science & Information Technology

You might also like to view...

One of the key components while creating a mobile website design is to have the most important information up-front and easily accessible.?

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What are some common post-installation tasks?

What will be an ideal response?

Computer Science & Information Technology

A(n) ________ is the portion of virus code that is unique to a particular computer virus.

A. virus signature B. encryption code C. compression code D. virus pattern

Computer Science & Information Technology

class InstanceofDemo{    public static void main(String[] args)   {        Parent object1 = new Parent();        Parent object2 = new Child();        System.out.println("object1 instanceof Parent: "            + (obj1 instanceof Parent));        System.out.println("object1 instanceof Child: "            + (obj1 instanceof Child));        System.out.println("object1 instanceof MyInterface: "            + (obj1 instanceof MyInterface));        System.out.println("object2 instanceof Parent: "            + (obj2 instanceof Parent));        System.out.println("object2 instanceof Child: "            + (obj2 instanceof Child));        System.out.println("object2

instanceof MyInterface: "            + (obj2 instanceof MyInterface));     }}The above code defines a parent class (named Parent), a simple interface (named MyInterface), and a child class (named Child) that inherits from the parent and implements the interface.Following program execution, what will be the output of the six println statements? What will be an ideal response?

Computer Science & Information Technology