Presentation is loading. Please wait.

Presentation is loading. Please wait.

Accessor Functions 04/13/11. Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member.

Similar presentations


Presentation on theme: "Accessor Functions 04/13/11. Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member."— Presentation transcript:

1 Accessor Functions 04/13/11

2 Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member functions control data Like buttons on watchLike buttons on watch

3 Access Specifiers  Indicate accessibility of class members  public: Open access to outside functions Open access to outside functions Member functions are usually public. Member functions are usually public.  private: Access restricted to other members of class Access restricted to other members of class Member variables private Member variables private  Example: sec6.2/rectangle.cpp

4 Accessor Functions  Main program can't directly access private data members.  Create accessor function to allow access. Name usually begins with “get” Name usually begins with “get”  dog.cpp

5 Review  ch6/review.cpp Why doesn't the program compile? Why doesn't the program compile? Use accessors to let the main get the degrees and scale. Use accessors to let the main get the degrees and scale. What would the accessor functions be? What would the accessor functions be?

6 TIMERa  Look at TIMERa exercise in sec6.2 directory.  Good exercise to do on your own.


Download ppt "Accessor Functions 04/13/11. Encapsulation  Like case on my watch Protect from outside Protect from outside Have member functions control data Have member."

Similar presentations


Ads by Google