Data Members - Object Oriented Programming - Lecture Slides, Slides of Object Oriented Programming

Data members, Encapsulated in the class, Public member functions, Interface to the class, Function Inside Class Body, Function Outside Class Body, Inline Functions are points you can learn in this Object Oriented Programming lecture.

Typology: Slides

2011/2012

Uploaded on 11/09/2012

bacha
bacha 🇮🇳

4.3

(41)

213 documents

1 / 16

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Object Oriented Programming
(OOP)
Lecture No. 8
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Data Members - Object Oriented Programming - Lecture Slides and more Slides Object Oriented Programming in PDF only on Docsity!

Object Oriented Programming

(OOP)

Lecture No. 8

Review

  • Class
    • Concept
    • Definition
  • Data members
  • Member Functions
  • Access specifier

Member Functions (contd.)

  • Define member function inside the class definition OR
  • Define member function outside the class definition - But they must be declared inside class definition

Function Inside Class Body

class ClassName {

public:

ReturnType FunctionName () {

Example

class Student{

int rollNo;

public:

void setRollNo(int aRollNo){ rollNo = aRollNo; }

};

Function Outside Class Body

class ClassName { … public: ReturnType FunctionName (); }; ReturnType ClassName :: FunctionName () { … }

Scope resolution operator

Inline Functions

  • Instead of calling an inline function compiler replaces the code at the function call point
  • Keyword ‘inline’ is used to request compiler to make a function inline
  • It is a request and not a command

Example

inline int Area(int len, int hi)

{

return len * hi;

}

int main()

{

cout << Area(10,20);

}

Example

class Student{

int rollNo;

public:

void setRollNo(int aRollNo){ … rollNo = aRollNo; }

};

Example

class Student{ … public: inline void setRollNo(int aRollNo); }; void Student::setRollNo(int aRollNo){ … rollNo = aRollNo; }

Example

class Student{ … public: inline void setRollNo(int aRollNo); }; inline void Student::setRollNo(int aRollNo){ … rollNo = aRollNo; }