Absolute C++ (4th Edition) part 60. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Inheritance Basics 597 For example the following are the first few lines from the body of the member function Hourly-Employee printCheck taken from Display void HourlyEmployee printCheck setNetPay hours wageRate cout n_ n cout Pay to the order of getName endl cout The sum of getNetPay Dollars n You might have wondered why we needed to use the member function setNetPay to set the value of the netPay member variable. You might be tempted to rewrite the start of the member function definition as follows void HourlyEmployee printCheck Illegal use of netPay netPay hours wageRate As the comment indicates this will not work. The member variable netPay is a private member variable in the class Employee and although a derived class like HourlyEmployee inherits the variable netPay it cannot access it directly. It must use some public member function to access the member variable netPay. The correct way to accomplish the definition of printcheck in the class HourlyEmployee is the way we did it in Display part of which was displayed earlier . The fact that name and netPay are inherited variables that are private in the base class also explains why we needed to use the accessor functions getName and getNetPay in the definition of HourlyEmployee printCheck instead of simply using the variable names name and netPay. You cannot mention a private inherited member variable by name. You must instead use public accessor and mutator member functions such as getName and setName that were defined in the base class. Recall that an accessor function is a function that allows you to access member variables of a class and a mutator function is one that allows you to change member variables of a class. Accessor and mutator functions were covered in Chapter 6. The fact that a private member variable of a base class cannot be accessed in the definition of a member function of a derived class often seems wrong to people. After all if you are an