August 2001
Beginner
482 pages
10h 52m
English
Just as non-class functions can have one or more default values, so can each member function of a class. The same rules apply for declaring the default values, as illustrated in Listing 13.2.
0: //Listing 13.2 Default values in member functions 1: #include <iostream> 2: 3: // Rectangle class declaration 4: class Rectangle 5: { 6: public: 7: // constructors 8: Rectangle(int width, int height); 9: ~Rectangle(){} 10: void DrawShape(int aWidth, int aHeight 11: bool UseCurrentVals = false) const; 12: private: 13: int itsWidth; 14: int itsHeight; 15: }; 16: 17: //Constructor implementation 18: Rectangle::Rectangle(int width, int height): 19: itsWidth(width), // initializations 20: itsHeight(height) ... |
Read now
Unlock full access