CMPT 212
Fall 1997
|
// file display.h void display(char c); // first display function. void display(int i); // second display function. bool display(char c, int i); // third display function. // file one.cpp ... char letter; int width; bool result; ... display(letter); // calls first display function. result = display(letter, width); // calls third display function. display(width); // calls second display function.
void display(char c, int i); bool display(char c, int i); // causes a compiling error.
void display(float f); void display(bool b); ... int i; ... display(i); // calls display(float).
void display(float f); void display(bool b); ... char c; ... display(c); // causes a compiling error.
void display(long x); void display(int i); ... unsigned int i; ... display(i); // causes a compiling error.
void display(char c, int size = 12, int x = 0, int y = 0); ... display('W'); // same as display('W', 12, 0, 0). display('W', 5); display('W', 5, 16, 10); display(); // causes a compiling error.
// bool.h #ifndef _bool_h_ #define _bool_h_ #if (__BORLANDC__ < 0x500) enum bool { false, true }; #endif #endifThe value __BORLANDC__ is set by the Borland system header files to be equal to the compiler's version number. This example may have to be adjusted to work with Microsoft's compilers. (Note that there are two underscores before and after BORLANDC.)
int x = 3; // x is an integer. int& y = x; // y is a reference to an integer.
int& y; // causes a compiling error.
int& y = x;as meaning "y is another name for x".
Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 22 Sep 1997. |