Select the correct rules for encapsulation. If any rules need to be imposed in a particular order, then say so, mentioning which rules.

a) Make all class member variables public members of the class.
b) Place the interface in the header file. What is the interface?
c) Place the implementation in a separate code file (with file extension required by your compiler: .cpp, .cxx, etc), called the implementation file. What is the implementation?
d) Having private members visible in the interface violates the philosophy of separating the interface from the implementation. Separate interface and implementation requires removal of all the private members from the class definition. You must put these in another part of the class definition in the implementation.


b) Place the interface in the header file. What is the interface? , and c) Place the implementation in a separate code file (with file extension required by your compiler: .cpp, .cxx, etc), called the implementation file. What is the implementation?

a) Having public data members violates encapsulation. The private members are part of the implementation, not part of the interface. Since a class in C++ cannot be split across two files and other C++ design reasons, the compromise of putting private members in the class definition was reached.
b) What is the interface? The interface is the class definition containing constructors, destructor, declarations of each basic operation of the class, declarations of friend functions. Grouped with the class definition are the declarations of ordinary functions and of nonmember overloaded operators and any needed comments that explain how to use functions.
c) What is the implementation? The implementation consists of the definitions of all member functions, overloaded operator definitions (members and nonmembers) with definitions of any helping functions or other additional items necessary to these definitions. Inclusion of the interface file in the implementation file will be necessary to compile the implementation file.
d) A class in C++ cannot be split across two files. The private members must be placed in the class definition.


Computer Science & Information Technology

You might also like to view...

A JTabbedPane

a. arranges GUI components into layers such that only one layer is visible at a time. b. allows users to access a layer of GUI components via a tab. c. extends JComponent. d. All of the above.

Computer Science & Information Technology

Before reviewing a document, you should ensure that your user name and initials are recorded in Word Options

Indicate whether the statement is true or false

Computer Science & Information Technology

In Excel the interest percentage on a loan is called the:

A) payment period. B) Future value (Fv). C) Present value (Pv). D) rate.

Computer Science & Information Technology

Your supervisor created a PowerPoint presentation and now she wants you to make the presentation more engaging for her audience. The presentation is about a new product line that your company is developing and the intended audience is a group of company stockholders. Your supervisor wants to include biographical data for each team member, so that the stockholders can visualize the team building the new product. Their ID photos are available to you, but they are too big. How can you make the pictures better fit in the presentation?

What will be an ideal response?

Computer Science & Information Technology