Using Microsoft Visual C++ 6.0 with
Data Structures and Other Objects (Second Edition)

These are the changes that I needed to make to ANSI Standard C++ code in order to use Microsoft Visual C++ 6.0. I have applied these changes to all of the code from Data Structures and Other Objects (Second Edition) by Michael Main and Walter Savitch. You may download a zip file containing all of the modified code from:

www.cs.colorado.edu/~main/vccode.zip

Please let me know if you spot any other features of ANSI Standard C++ that are not supported by Microsoft Visual C++ 6.0.

Michael Main (main@colorado.edu)


List of Changes

  1. It is easiest to use the file extension .cpp instead of .cxx, so I have changed each file extension to .cpp.

  2. These items from <cstdlib> are not part of std in VC++ 6.0: So, for example, you must change any std::size_t to simply size_t.

  3. Initialization of static member constants in a header file is forbidden. Therefore, I suggest that you use an enum instead. For example, instead of
        static const size_t CAPACITY = 30;
    
    You can use this enum member:
        enum { CAPACITY = 30 };
    
    When you use this enum instead of a static member constant, you must also delete the member constant's declaration from the implementation file. Also, some uses of the constant in an implementation might need a type cast back to the size_t or int type. For example:
        fill_n(data, (size_t) CAPACITY, 0);
    

  4. A few programs have this error message:
    error C2871: 'std' : does not exist or is not a namespace
    To fix this, remove the directive for using namespace std;. (But remove the directive only if the error occurs.) This problem is caused because certain header files (such as cstdlib and cassert do not declare the std namespace in VC++ 6.0.

  5. In VC++, the std::string class is defined within <iostream>. Therefore, in the str_demo.cpp program of Chapter 4 we must specify the complete type name main_savitch_4::string if we want to use our own string class.

Using a Namespace There are several spots in our original code where we forgot to use a namespace: These were bugs in our original code, not caught because it wasn't required by the g++ compiler.
Building VC++ Projects for the Data Structures Code
    Each program can be put in a project by itself. For example, demo2.cpp from Chapter 2 can be put in a project called demo2 by these steps: