O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calling the Functions

The only difference that results from calling the functions in the new modules is the need to qualify function names with their namespace. Listing 8.5 shows the new main.cpp.

Listing 8.5. main.cpp Calling on Separately Compiled Modules
 1: #include <iostream> 2: *3: #include "PromptModule.h" *4: #include "ErrorHandlingModule.h" 5: 6: using namespace std; 7: 8: float GetDividend(void) 9: { 10: float Dividend = 0; 11: 12: cout << "Dividend: "; 13: cin >> Dividend; 14: 15: return Dividend; 16: } 17: 18: float GetDivisor(void) 19: { 20: float Divisor = 1; 21: 22: cout << "Divisor: "; 23: cin >> Divisor; 24: 25: return Divisor; 26: } 27: 28: float Divide 29: (const float theDividend,const float theDivisor) 30: { 31: return (theDividend/theDivisor); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required