Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

 True or false? 1) A derived class inherits the constructor functions of the b

ID: 3535601 • Letter: #

Question

Â

True or false?

1) A derived class inherits the constructor functions of the base class.

2) Overloaded functions must have unique function signatures.

3) The function signature of an overridden function must be unique.

4) A virtual function is called based on the dynamic data type of the calling object.

5) A friend function of a class has access to all of the public, protected, and private members of the class.

Â

Multiple choice

6) Assume that the following function prototype is provided in the declaration of a class nambed Myclass:

friend void input(istream&, Myclass&);

 Which of the following is a valid function header for this prototype?

 a) friend void input(istream& in, Myclass C)

 b) friend void Myclass::input(istream& in, Myclass C)

 c) Myclass::input(istream& in, Myclass C)

 d) void input(istream& in, Myclass)

 e) Myclass::friend input(istream& in)

Â

7) Assume that the following function prototype is provided in the declaration of a class named Myclass:

virtual void input(istream&);

 Which of the following is a valid function header for this prototype?

 a) virtual void input(istream& in)

 b) virtual void Myclass::input(istream& in)

 c) void Myclass::input(istream& in)

 d) void input(istream& in)

e) void Myclass::virtual input(istream& in)

Programming problems

http://imgur.com/bN8XxXB http://imgur.com/RqZaddc

8) Add a recursive method to the BinaryTree class that returns a count of the number of leaf nodes in the tree.

9) Write a program that uses the BinaryTree class to order a set of data read from a data file. Your program should open a data file, read the data and store it in your tree, then print the data using the inOrder print method.

Explanation / Answer

1.true

2.true

3.false

4.true

5.false

6. c) Myclass::input(istream& in, Myclass

7. b) virtual void Myclass::input(istream& in

8.

int countLeaves(Node node,int count){ if(node==null) return 0; if(node.left==null && node.right==null){ return 1+count; }else{ int lc = countLeaves(node.left, count); int total = countLeaves(node.right, lc); return total; } }