a) Examine the following class declaration: class DateType { public: void Initia
ID: 3728206 • Letter: A
Question
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.
Explanation / Answer
Hi, I have aswered first 4 Question.
Please repost others in separate post.
i) Which of the following statements in a client program correctly prints out the year of the variable day1 of type DateType?
Ans: D. cout << day1.YearIs();
ii) Which of the following statements in a client program correctly initializes a variable day1 of type DateType to 10/12/90?
Ans: C. day1.Initialize(10,12,90);
b) The members of a class are public by default.
Ans: False, private by default
c) The member variables and functions declared following the word private are accessible only to the class's member functions, while those declared following the word public are accessible to the client program.
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] = item; //first line
length++; //second line
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.