Question: a) Examine the following class declaration: class DateType { public: void Initialize(int, int, int); int YearIs() const; // returns year int MonthIs() const; // returns

a) Examine the following class declaration:

class DateType

{

public:

void Initialize(int, int, int);

int YearIs() const; // returns year

int MonthIs() const; // returns month

int DayIs() const; // returns day

private:

int year;

int month;

int day;

};

i) Which of the following statements in a client program correctly prints out the year of the variable day1 of type DateType?

A. cout << day1.YearIs;

B. cout << YearIs(day1);

C. cout << YearIs.day1;

D. cout << day1.YearIs();

E. The year cannot be printed by a client program.

----------------

ii) Which of the following statements in a client program correctly initializes a variable day1 of type DateType to 10/12/90?

A. Initialize(10,12,90);

B. day1.month = 10;

day1.day = 12;

day1.year = 90;

C. day1.Initialize(10,12,90);

D. cin>>month>>day>>year;

E. The client program cannot initialize the date.

---------------

b) The members of a class are public by default.

A) True

B) False

-----------------

c) The member variables and functions declared following the word __(1)___ are accessible only to the class's member functions, while those declared following the word __(2)___ are accessible to the client program.

1.

A. public

B. private

2.

A. public

B. private

-----------

d) Fill in the first and second line (see comments) in the following function (use the specification given with this exam, if needed).

void UnsortedType::InsertItem(ItemType item)

// Post: item is in the list.

{

info[length] = ____________ ; //first line

______________ ; //second line

}

e) Describe what information hiding means.

f) Describe why we use header files, implementation files, and specification files. Include what each file contains.

g) Use a typedef statement to declare twoDimType, which is a two dimensional array with 10 rows and 25 columns. Then define a variable, Table1, of type twoDimType.

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!