Chapter 12


1.

What is polymorphism?

it means functions with the same name but different code

2.

What does it mean to override a function?

to use the same name, return type, and parameters, but to change the code in the function

3.

How is overriding different from overloading?

in overloading, you change the parameters; in overriding you do not.

4.

What is the syntax for a child class to inherit from two base classes (classa and classb)?

 childclass: public classa,classb

5.

What is a function’s interface?

its declaration line(i.e., its return type, name, and parameters)

6.

What is a function’s implementation

the actual code in the function

7.

How do you handle the situation where two base classes have the same function?

override the function in the derived class

8.

What is a virtual function?

a function that must be overridden in any derived class

9.

What is an abstract class?

a class that cannot be directly instantiated, but must be inherited to be used

10.

How do you create an abstract class?

by making any of its functions a pure virtual function.

Answers

1.

It means functions with the same name but different code

2.

To use the same name, return type, and parameters, but to change the code in the function

3.

In overloading, you change the parameters; in overriding you do not.

4.

childclass: public classa,classb

5.

Its declaration line (i.e., its return type, name, and parameters)

6.

The actual code in the function

7.

Override the function in the derived class

8.

A function that must be overridden in any derived class

9.

A class that cannot be directly instantiated, but must be inherited to be used

10.

By making any of its functions a pure virtual function.




C++ Programming Fundamentals
C++ Programming Fundamentals (Cyberrookies)
ISBN: 1584502371
EAN: 2147483647
Year: 2005
Pages: 197
Authors: Chuck Easttom

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net