Encapsulation, Data Hiding - Introduction to Programming - Lecture Slides, Slides of Computer Programming

Encapsulation, Data Hiding, Friend Function, Prototype of functions, Straight Line, Quadratic, Limitations, Transitive, Associative, value of top Secret are the key points of this lecture.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

somo
somo 🇮🇳

4.8

(4)

70 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Programming
Lecture 29
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Encapsulation, Data Hiding - Introduction to Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Introduction to Programming

Lecture 29

Private

Public

Friend

Friend Function

Friend Function

class Date

friend functionName ( Argument_list ) ;

Example 1

class myClass

{

friend increment ( myClass , int ) ; private: int topSecret ; public: myClass ( ) { topSecret = 100 ; } void Display ( ) { cout<< “The value of topSecret is “ << topSecret ; }

} ; Docsity.com

Example 1

void Increment ( myClass A , int i )

{

A.topSecret += i ;

}

Example 1: Output

The value of topSecret is 100

The value of topSecret is 110

Example 2

class myClassTwo ;

class myClassOne

{

private : int topSecret ; public : void Display ( ) ; myClassOne ( ) { topSecret = 100; } friend AddBoth ( myClassOne , myClassTwo ) ;

} ;

Example 2

main ( )

myClassOne A ;

myClassTwo B ;

A.Display ( ) ;

B.Display ( ) ;

AddBoth ( A , B ) ;

Example 2

int AddBoth ( myClassOne A , myClassTwo B )

{

cout << “The value of topSecret in myClassOne object is” << A.topSecret ;

cout << “The value of topSecret in myClassTwo object is”<< B.topSecret ;

cout << “The sum of topSecret values in “ << “myClassOne and myClassTwo object is ” << A.topSecret + B.topSecret ;

}

y = mx + c

Slope (^) Intercept on y axis

Straight Line

Straight Line

class straightLine

double slope , intercept ;

// member function

Quadratic

class quadratic

{

private :

double a , b , c ;

// member function

} ; Docsity.com

Limitations

It is NOT Transitive

It is NOT Associative