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.
b) Don’t make member variables public. , and d) There are some member functions that shouldn’t be public, but most should be public.
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.
You might also like to view...
Give the three criteria for a correct recursive void-function.
What will be an ideal response?
Which of the following is NOT true about how the Internet began?
A) The original ARPANET had only four locations, called nodes. B) The Internet started as a U.S. Department of Defense ARPA project in the 1950s. C) It took about 10 years to develop the technology. D) In 1958, President Eisenhower created the Advanced Research Projects Agency (ARPA) to jump-start U.S. technology for the military.
Describe Extensible Authentication Protocol (EAP) and explain where it is used.
What will be an ideal response?
Currently, there are two major techniques used to develop programs and their procedures. Name and describe them.
What will be an ideal response?