Page 63 - DCAP404 _Object Oriented Programming
P. 63
Object-oriented Programming Kumar Vishal, Lovely Professional University
Notes Unit 3: Review of Functions
CONTENTS
Objectives
Introduction
3.1 The MAIN Function
3.2 Function Overloading
3.3 Inline Functions
3.4 Default Arguments
3.5 Function Prototyping
3.6 Summary
3.7 Keywords
3.8 Review Questions
3.9 Further Readings
Objectives
After studying this unit, you will be able to:
Recognize the functions
Describe the function overloading
Explain the inline functions
Discuss the default arguments
Describe the function prototyping
Introduction
Those who are familiar with language C would agree that writing a C program is nothing more
than writing C functions (including the main function). C++ on the other hand is all about
writing codes for defining and manipulating classes and objects.
Conceptually an object may have only data members specifying its attributes. However, such
an object would serve no useful purpose. For the purpose of establishing communication with
the object it is necessary that the object provide methods, which are C like functions. Though
C++ functions are very similar to C functions, yet they differ significantly as you will discover
in this unit.
3.1 The MAIN Function
An application written in C++ may have a number of classes. One of these classes must contain
one (and only one) method called main method. Although a private main method is permissible
in C++ it is seldom used. For all practical purposes the main method should be declared as
public method.
56 LOVELY PROFESSIONAL UNIVERSITY