This module continues the discussion of the class begun in Module 8. It examines a number of class-related topics, including overloading constructors, passing objects to functions, and returning objects. It also describes a special type of constructor, called the copy constructor, which is used when a copy of an object is needed. Next, friend functions are described, followed by structures and unions, and the ‘this’ keyword. The module concludes with a discussion of operator overloading, one of C++’s most exciting features | Module 9 A Closer Look at Classes Table of Contents CRITICAL SKILL Overload CRITICAL SKILL Assign CRITICAL SKILL Pass objects to CRITICAL SKILL Return objects from CRITICAL SKILL Create copy CRITICAL SKILL Use friend CRITICAL SKILL Know the structure and CRITICAL SKILL Understand CRITICAL SKILL Know operator overlaoding CRITICAL SKILL Overlaod operators using member CRITICAL SKILL Overlad operators using nonmember This module continues the discussion of the class begun in Module 8. It examines a number of class-related topics including overloading constructors passing objects to functions and returning objects. It also describes a special type of constructor called the copy constructor which is used when a copy of an object is needed. Next friend functions are described followed by structures and unions and the this keyword. The module concludes with a discussion of operator overloading one of C s most exciting features. 1 C A Beginner s Guide by Herbert Schildt CRITICAL SKILL Overloading Constructors Although they perform a unique service constructors are not much different from other types of functions and they too can be overloaded. To overload a class constructor simply declare the various forms it will take. For example the following program defines three constructors Overload the constructor. include iostream using namespace std class Sample public int x int y Overload the default constructor. Sample x - y 0 ------------------------ Constructor with one parameter. Sample int i x y i -----------Overload the Sample constructor. Constructor with two parameters Sample int i int 1 x i y j int main Sample t invoke default constructor Sample tl 5 use Sample int Sample t2 9 10 use Sample int int cout n cout n cout n return 0 The .