Page 75 - DCAP404 _Object Oriented Programming
P. 75
Object-oriented Programming Manmohan Sharma, Lovely Professional University
Notes Unit 4: Classes and Objects
CONTENTS
Objectives
Introduction
4.1 Specifying a Class
4.2 Defining Member Functions
4.3 Creating Class Objects
4.3.1 Objects as Function Arguments
4.3.2 Returning Objects
4.4 Accessing a Member of Class
4.5 Access Specifiers
4.5.1 The Public Access Specifier
4.5.2 The Private Access Specifier
4.5.3 The Protected Access Specifier
4.6 Summary
4.7 Keywords
4.8 Review Questions
4.9 Further Readings
Objectives
After studying this unit, you will be able to:
Recognize how to specify a class
Define the member functions
Explain the creation of class objects
Access the class members
Discuss the access specifiers
Introduction
Classes and objects are at the core of object-oriented programming. Writing programs in C++
essentially means writing classes and creating objects from them. In this unit you will learn to
work with the same.
It is important to note the subtle differences between a class and an object, here. A class is a
template that specifies different aspects of the object it models. It has no physical existence. It
occupies no memory. It only defines various members (data and/or methods) that constitute the
class.
An object, on the other hand, is an instance of a class. It has physical existence and hence occupies
memory. You can create as many objects from a class once you have defined a class.
68 LOVELY PROFESSIONAL UNIVERSITY