Thursday, December 4, 2014

cs Sep 11



operator overloading

ostream operator <<(ostream, int)

polymorphism

bitwise left shift

pass by value and pass by reference

pass by value : pass a copy of the argument to the function (in definition and declaration of the function)
pass by reference : pass location, memory address of the argument to the function.

operator <<(cout,x)

pass by reference : specify &

1. pass by value

int f(int x)

x=2

int f (int *p)  // pass by pointer , passing an address which is getting changed , pass by value but has the effect of pass by reference;;

as if we do p++; but the value that it is pointing to is not changed..

*p = 2



int f(int &x) // pass by reference

x = 2

argument is the "actual parameter" passed to the function
placeholder inside the function is the "formal parameter"

cout : variable or name of an object.

Abstraction : hide "details" : to make it easier to understand and use. hide details behind an interface.

interface : how do you use it
implementation : put the details how something is done.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home