0% found this document useful (0 votes)
25 views

Classes and Objects

The document discusses objects and classes in C++. It describes two methods for defining member functions - within the class definition, which makes them inline by default, and outside the class definition. It provides examples of calculating the area of a rectangle using a class with member functions defined both internally and externally. The examples demonstrate how to declare and define classes, member functions, and objects in C++.

Uploaded by

Fahim Shaik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Classes and Objects

The document discusses objects and classes in C++. It describes two methods for defining member functions - within the class definition, which makes them inline by default, and outside the class definition. It provides examples of calculating the area of a rectangle using a class with member functions defined both internally and externally. The examples demonstrate how to declare and define classes, member functions, and objects in C++.

Uploaded by

Fahim Shaik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Objects and Classes

Dr. J. Sangeetha/CSE/SRC/SASTRA 1
Dr. J. Sangeetha/CSE/SRC/SASTRA 2
Dr. J. Sangeetha/CSE/SRC/SASTRA 3
Dr. J. Sangeetha/CSE/SRC/SASTRA 4
Dr. J. Sangeetha/CSE/SRC/SASTRA 5
Dr. J. Sangeetha/CSE/SRC/SASTRA 6
Dr. J. Sangeetha/CSE/SRC/SASTRA 7
Method : 1 – Defining member
function inside the class – By default
inline

Dr. J. Sangeetha/CSE/SRC/SASTRA 8
Ex : 2

Dr. J. Sangeetha/CSE/SRC/SASTRA 9
Dr. J. Sangeetha/CSE/SRC/SASTRA 10
Ex : 3

Dr. J. Sangeetha/CSE/SRC/SASTRA 11
Dr. J. Sangeetha/CSE/SRC/SASTRA 12
Example : 2

Dr. J. Sangeetha/CSE/SRC/SASTRA 13
Dr. J. Sangeetha/CSE/SRC/SASTRA 14
Method 2 : Member function definition outside the class

Dr. J. Sangeetha/CSE/SRC/SASTRA 15
Dr. J. Sangeetha/CSE/SRC/SASTRA 16
Dr. J. Sangeetha/CSE/SRC/SASTRA 17
Dr. J. Sangeetha/CSE/SRC/SASTRA 18
Dr. J. Sangeetha/CSE/SRC/SASTRA 19
Dr. J. Sangeetha/CSE/SRC/SASTRA 20
Dr. J. Sangeetha/CSE/SRC/SASTRA 21
Dr. J. Sangeetha/CSE/SRC/SASTRA 22
Dr. J. Sangeetha/CSE/SRC/SASTRA 23
Dr. J. Sangeetha/CSE/SRC/SASTRA 24
Counter Example

Dr. J. Sangeetha/CSE/SRC/SASTRA 25
Dr. J. Sangeetha/CSE/SRC/SASTRA 26
Calculate the area of a rectangle and
display it.

Dr. J. Sangeetha/CSE/SRC/SASTRA 27
Dr. J. Sangeetha/CSE/SRC/SASTRA 28
Dr. J. Sangeetha/CSE/SRC/SASTRA 29
Dr. J. Sangeetha/CSE/SRC/SASTRA 30
Dr. J. Sangeetha/CSE/SRC/SASTRA 31
Dr. J. Sangeetha/CSE/SRC/SASTRA 32
Dr. J. Sangeetha/CSE/SRC/SASTRA 33
Dr. J. Sangeetha/CSE/SRC/SASTRA 34
Dr. J. Sangeetha/CSE/SRC/SASTRA 35

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy