Day 5. Organizing into Functions
Although object-oriented programming has shifted attention from functions and toward objects, functions nonetheless remain a central component of any program. Global functions can exist outside of objects and classes, and member functions (sometimes called member methods) exist within a class and do its work.
Today, you will learn
• What a function is and what its parts are
• How to declare and define functions
• How to pass parameters into functions
• How to return a value from a function
You’ll start with global functions today, and tomorrow you’ll see how functions work from within classes and objects as well.
What Is a Function?
A function is, in effect, a subprogram that can act on data and return a value. ...