# Module 15: Functions in C++

MODULE OVERVIEW

This module explores functions in C++ programming and introduces advanced
function concepts that support flexible, reusable and structured code
development.



Learners will understand call by reference and return by reference, function
overloading, default arguments and inline functions.



The module also covers static class members, friend functions and virtual
functions, helping learners understand how functions work within C++ and how
they support object-oriented programming.




WHAT WILL BE COVERED


15.1 CALL BY REFERENCE, RETURN BY REFERENCE

Understand how call by reference allows functions to work with references to
variables and how return by reference enables functions to return references to
values. Learn how these techniques can be used to access and work with data
efficiently.


15.2 FUNCTION OVERLOADING AND DEFAULT ARGUMENTS

Explore function overloading and how multiple functions can share the same name
with different parameter lists. Learn how default arguments allow functions to
use predefined parameter values when arguments are not explicitly supplied.


15.3 INLINE FUNCTION

Understand the concept of inline functions in C++ and how they are used to
define functions with inline expansion as a compiler suggestion. Explore their
role in writing concise functions for suitable operations.


15.4 STATIC CLASS MEMBERS

Learn about static class members and how they belong to a class rather than
individual objects. Understand how static data members and static member
functions can be used within class-based programming.


15.5 FRIEND FUNCTIONS

Explore friend functions and how they can access private and protected members
of a class when declared as friends. Understand how friend functions work and
their role in C++ programming.


15.6 VIRTUAL FUNCTIONS

Understand virtual functions and how they support runtime polymorphism in C++.
Learn how virtual functions allow derived classes to provide their own
implementations and how function calls can be resolved dynamically.


SKILLS YOU WILL GAIN

 * Understanding call by reference and return by reference.

 * Implementing function overloading.

 * Using default arguments in functions.

 * Working with inline functions.

 * Understanding static class members.

 * Implementing friend functions.

 * Using virtual functions for runtime polymorphism.


LEARNING OUTCOMES

By the end of this module, learners will be able to:

 * Implement call by reference and return by reference.

 * Create overloaded functions with different parameter lists.

 * Apply default arguments in function definitions.

 * Understand and implement inline functions.

 * Work with static data members and static member functions.

 * Use friend functions to access class members.

 * Understand and implement virtual functions for runtime polymorphism.


CERTIFICATION ALIGNMENT

This module develops advanced function concepts and object-oriented programming
skills that support the development of C++ applications. The topics covered
contribute to the programming knowledge learners build throughout the C and C++
training program.


CONTINUE TO THE NEXT MODULE

Continue to Module 16: Constructors and Destructor to learn how constructors
initialise objects, explore different constructor types, understand memory
allocation using new and delete, and work with destructors in C++.