Downloading Horstmann's Graphics Libraries and Creating a Visual C++ project that Uses Them

for ANSI Standard C++
JL Popyack


Horstmann provides an ASCII-based (text only) graphics package. This package does not require the use of any specialized graphics libraries, so it should work on any ANSI Standard C++ compiler.

Before you can do graphics, you need to do some code library installation.

Download the following zip file: , which contains Horstamnn's code libraries for graphics, and also other code used in his text.
(NOTE: This is a local copy; the original can be found at http://www.horstmann.com/ccc/ccc3e.zip)

Unzip these files in a reasonable spot on your hard drive.

Create a new project, and make a standard console application.

Add the cccfiles directory to the include path, in whatever way this is done for your compiler (users of Visual C++ v6.0 or Visual Studio .NET can see instructions for those compilers by clicking the appropriate link).

Add ccc_win.h, ccc_asc.cpp and ccc_shap.cpp to the project (also ccc_asc.h and ccc_shap.h), by clicking on Project -> Add to Project -> Files, and selecting these files.

Now, create a new source file and add it to the project.

#include "ccc_win.h"

int ccc_win_main()
{
  Point origin(0,0) ;
  Point p(4, 2.5);
  Line myLine(origin, p);

  Circle smallCircle(p, 2.2);
  Circle bigCircle(origin, 6);
  cwin << origin << p << myLine
       << smallCircle << bigCircle;

  return 0;
}

 

Compile and run your program. If you're lucky, all goes well, you should produce a console window with the following output.

(Click here to see the results produced by the same source program when used in a graphics programming environment.)