Program 5

Home Windows C++ 241 C++ 242 Contact Info Contents

Program 5 - February 12

Up

This assignment requires you to make some use of operator overloading. You may choose to do one of the exercises I list from chapter 8, make an enhancement to your TicTacToe program or propose another program to me.  Review the choices carefully, particularly if you are doing one of the mathematical options. It doesn't make sense to do one of these unless you already have a very firm understanding of the underlying math.

From Chapter 8

You may do any of the following: 8.8, 8.15, 8.16, 8.17, 8.19. All but 8.8 are mathematical in nature. Some of these are very difficult but quite interesting if you are mathematically inclined. I personally find 8.19 unique because it performs operations on data structures representing polynomials rather than on numeric values. Some of the exercises don't mention overloading << to provide output but you should do that anyway - otherwise how do you  get to see your  values.

TicTacToe Enhancement

Provide output by overloading the << operator. You may do this in either of two ways.

If you have a display object, have the board display by using code like this:

TicTacToe board;
TicTacToeDisplay display;
...
display << board;

In this case, the function would be a member of display.

If you are not using a display object, have the board display this way:

TicTacToe board;
...
cout << board;

In this case, you would need to use a friend function, because you can't change the ostream class.

Ideally, you could provide both ways of doing output. Provide a simple form of display using cout, and a fancier output using your display class.

Something New

If you aren't mathematical and tired of tic-tac-toe, you can write your own class that makes use of operator overloading. It should involve input, output and some other operations. If you want to do this, you need to discuss it with me (in person or by mail) first so I can review its feasiblility and decide if it's sufficient for the assignment.

Up

Home Windows C++ 241 C++ 242 Contact Info Contents

Copyright © 2000  Charlie Poole. All rights reserved.
Revised: July 15, 2002 - cpoole@ctc.edu