3.1 INTRODUCTION TO FUNCTIONS

Functions are small piece of code performing a particular task. They help in modularizing our program. A function is a small independent unit of a program. Any program contains one or more function. The function (with name) main() is compulsory. The execution of the program normally starts with function main().

The main function during execution can call other functions. Invoking a function is referred to as calling that function. At the end, function returns the control back to the point from where it was called. Hence, typically return statement is the last statement of a function.

Functions can return any non-aggregate data type, including reference or void. From aggregate data types, functions can return structures ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.