lecture-8b - 1 C+ Classes: Continued Object Oriented...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming C++ Classes R.B. Lenin Winter 2006 DA-IICT 1 C++ Classes: Continued
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Object Oriented Programming C++ Classes R.B. Lenin Winter 2006 DA-IICT const (Constant) Objects and const Member Functions • Principle of least privilege • Only give objects permissions they need, no more •K e y w o r d const • Specify that an object is not modifiable • Any attempt to modify the object is a syntax error • For example: const time noon( 12, 0, 0 ); • Declares a const object noon of class time and initializes it to 1 2 noon
Background image of page 2
3 Object Oriented Programming C++ Classes R.B. Lenin Winter 2006 DA-IICT const (Constant) Objects and const Member Functions (II) const objects require const functions – Functions declared const cannot modify the object const specified in function prototype and definition Prototype: ReturnType FunctionName(param1,param2…) const; Definition: ReturnType FunctionName(param1,param2…) const { …}; Example: int A::getValue() const {return privateDataMember};
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT325 taught by Professor Maniklaldas during the Spring '09 term at Punjab Engineering College.

Page1 / 13

lecture-8b - 1 C+ Classes: Continued Object Oriented...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online