Page 1 of 1

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

Posted: Fri Apr 29, 2022 6:49 am
by answerhappygod
1. 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.
2. Some of the statements about separate compilation follow.
Which are correct? Comment on all the answers in the explanation
section, including the ones that are wrong.
a) Separate files are a big bother. There is no compelling
advantage to separate files.
b) Placing client and class implementations in separate files
enhances project development. How?
c) Separate files for interface and implementation enhance
reuse. How?
d) Separating interface and implementation can save considerable
time. How?
3.Which of the following are the correct preprocessor commands
necessary to prevent multiple inclusions of header files? If there
is an answer here that works to prevent multiple inclusion,
carefully describe how it works in the explanation.
a)#include “header.h”
b)#define HEADER_H
#ifndef HEADER_H
//declarations for header.h go here
#endif
c)#ifndef HEADER_H
#define HEADER_H
// declarations for header.h go here #endif
d)#ifndef HEADER_H
//declarations for header.h go here