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)
.cpp
instead of .cxx
, so I have changed each file
extension to .cpp
.
<cstdlib>
are not part of std
in VC++ 6.0:
rand
size_t
std::size_t
to simply size_t
.
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);
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.
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.
mystring.h
must use
std::istream
and std::ostream
.
stack2.h
, stack2.template
and queue2.template
must use
main_savitch_6B::
with each list function, such as
main_savitch_6B::list_clear
. (This can't be done with a
using directive because the classes are template classes. On some
compilers, this would be handled automatically by the Koenig lookup
described on page 359, but VC++ does not seem to use the Koenig
lookup in this situation, perhaps because it is within a template.)
blob.cxx
is missing the directive to use std
.
demo2
.cpp
file that is part
of the projects. If you wish, you may also add the .h
files to the project, but this doesn't seem to be required in order
to build (they will show up as external dependencies in the file
view). You also do not need to add the .template
files to the project (they also show up as external dependencies.)