Hands-on 2a

Functions, Modules

Start code: session2-start.tar.gz

Using a function

  • Download the start code and unpack it in your working area (directory Project):
$ tar xzvf session2-start.tar.gz
  • Inspect, compile and run the program getArea.cxx.

Add functions

  • Add a new function double getRectangleArea(double, double) which will return the area of a rectangle given its sizes a and b. When the new function is added, add also a test in the main() function.

  • Add another function, which will return a boolean function. Invent yourself its meaning, give it a meaningful name and arguments. When the new function is added, add also a test in the main() function.

Using modules

  • Split the code in three files: myFunctions.h, myFunctions.cxx, main.cxx

  • Compile and run the program again.