![]() |
CMPT 212
Fall 1997
|
![]() |
The following sections of Prata should be a review:
|
// file multiply.cpp #include "multiply.h" int times10(int x) { // return x*10; // function definition. } // // file main.cpp #include "multiply.h" int main() { int number; cin >> number; cout << times10(number); // function is called here. return 0; } // file multiply.h int times10(int x); // function prototype.
// file multiply.cpp #include "multiply.h" static int times2(int x); // function prototype. int times10(int x) { // return x*10; // function definition. } // int times8(int x) { // return 4*times2(x); // function definition. } // static times2(int x) { // return x+x; // function definition. } // // file multiply.h int times10(int x); // function prototype. int times8(int x): // function prototype. // file main.cpp #include "multiply.h" int main() { int number; cin >> number; cout << times10(number); cout << times8(number); cout << times2(number); // causes a compiling error. return 0; }
![]() Return to lecture notes index |
|
This page is maintained by simpson@cs.sfu.ca. | Last updated on 12 Sep 1997. |