Presentation is loading. Please wait.

Presentation is loading. Please wait.

Const Parameters & In Line Functions 04/15/11. Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about.

Similar presentations


Presentation on theme: "Const Parameters & In Line Functions 04/15/11. Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about."— Presentation transcript:

1 Const Parameters & In Line Functions 04/15/11

2 Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about arrays

3 Pass Objects By-reference  More efficient  Opens possibility of changing Object  const in front to protect  point1.cpp void reflection_of(const Point &C, double v_axis);

4 Inline Function  Can give the function definition within the class definition.  Point class on next slide has in-line functions. One of them is the default constructor.

5

6 Constant Function  Member function that promises not to change any of the object's data members.  Add const after prototype double get_degrees( ) const;  tconstr.cpp  Should rise() or input_T() be const?

7 Circle Example  Write a class declaration for a class called Circle with a private data member called radius. Write an accessor function for the radius. Write a constructor to initialize the radius and a default constructor. Write a member function, findArea(), to find the area of the Circle.

8 Design the Class  Attributes?  Behaviors?

9 Next Time  Read 6.3 & 6.4  friend functions and overloaded operators


Download ppt "Const Parameters & In Line Functions 04/15/11. Next Time  Quiz, Monday, 04/18/11  Over 5.2 and 5.3 void functions pass-by-reference  Read 7.1 about."

Similar presentations


Ads by Google