Purchase Solution

Virtual Functions in Derived Classes that have Non-Virtual Destructors

Not what you're looking for?

Ask Custom Question

I am attempting to complete Assignemt Exercise 13.12 in the Deitel&Deitel 5th edition version of C++ How to program. I am running into some early errors in trying to incorporate the Date class into the existing Employee inherited class heirarchy. One issue is that I'm getting erros in the dervied classes that there are virtual functions in derived classes that have non-virtual destructors. I'm not sure what is going on at this point.

Purchase this Solution

Solution Summary

The virtual functions in derived classes that have non-virtual destructors are determined.

Solution Preview

See attached

We need to have virtual destructors for virtual functions.

The order of execution of destructor in an inherited class during a clean up is like this.
1. Derived class destructor
2. Base class destructor

A difference between a destructor (of course also the constructor) and other member functions is that, if a regular member function has a body at the derived class, only the version at Derived class gets executed. Whereas in case of destructor, both derived as well as base class versions get executed.

For example,

#include <iostream.h>
class Base
{
...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.