------------------------------------------------------------------------------
MC logo
PrintMe2 Class
[^] Code Examples
------------------------------------------------------------------------------
<<PrintMe Class printme2.h PrintMeLots Class>>
#ifndef _PRINTME2_H_
#define _PRINTME2_H_

#include <iostream>

/*
 * This class is constructed with an integer, which it
 * will print surrounded by [].
 */
class PrintMe2 {
    private:
        int num;                // Here is the number.
    public:
        // Remember the number.
        PrintMe2(int m) { num = m; }

        // Print the string.
        virtual void print() { cout << "[" << num << "]"; }
};

#endif

The only difference between PrintMe and PrintMe2 (besides the names) is the declaration of the print function as virtual. That declaration modifies the behavior of the function, as we'll see later.
<<PrintMe Class PrintMeLots Class>>