Module2 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Classes and Objects

Key Concepts

> Usin� tructurea > Static data membert1


), Crt>,;1.tinij a da11>1; > Static member functions
> Defining member functions > Using a.miys or objcClS
> Crpatinl( obJ\•tW. > Passing object.a ai; para.mPter&
> Using ohjptt.s > Making function• friendly to cJru,
), lnJine member functions > Functions returning ohjf'<1H
> Nc.i;ted member functions > const member funC'.tion"
> Private mt>mher functiona > Pointers to members
> Arrays OJ,j, dass members > Using den?ferencing operator-a
> Storage ofobj..cti; > Local classes

15-1 Intr0duction

The most important feature ofC++ is the "class•. Its significance is highlighted by the £act
that Stroustrup initially gave the name "'C with classes" to his new language. A class is an
� We may use objects as funetion argument,.
� A function declared as a friend is not in the scope of the class t.o which it has beeo
declared as friend. It has full aeeess to the private members of the class.
¢> A function can also re.turn an object.
¢> If a member function does not alter any data in the class, then we may declare it as a
const member function. The keyword con&t is appended to the function prototype.
� It is also possible to define and use a class inside a function. Such a class is called a local
class.

Key Terms
> abstract data type > obj.as
> arrays of objecta > pass-by-reference
> class > pass-by-value
> class declaration > period operator
> class members > private
> class variables > prototype
> const member function.a > public
> data biding > scope operator
> data membero > scope resolution
> derefercncmg operator > static data membt,,n
> dot operator > static member functions
> element.a > static variables
> encap"ulatio11 > struct
> friend function, > structure
> inheritnnC4;1 > structure members
> inline functions > structur& name
> local cla�s > structure tag
> member functions > template
> nesting of member functions

You might also like