C + + lập trình viên có thể kiểm tra và sử dụng các mối quan hệ giữa các thao tác của mảng và con trỏ để lợi thế của riêng mình. Trong phần này, bạn thấy rằng ¼ chỉ mục trong một mảng liên quan đến hoạt động toán học đơn giản được thực hiện trên con trỏ. | Session 18 Active Classes 247 Writing Member Functions Outside of the Class For larger functions putting the code directly in the class definition can lead to some very large unwieldy class definitions. To prevent this C lets us define member functions outside of the class. When written outside the class definition our addCourse method looks like this class Student public int nSemesterHours hours earned toward graduation float gpa add a completed course to the record float addCourse int hours float grade float Student addCourse int hours float grade float weightedGPA weightedGPA nSemesterHours gpa now add in the new course nSemesterHours hours weightedGPA grade hours gpa weightedGPA nSemesterHours return gpa Here we see that the class definition contains nothing more than a prototype declaration for the function addCourse . The actual function definition appears separately. Part IV-Saturday Evening Session 18 A declaration defines the type of a thing. A definition defines the contents of a thing. 248 Saturday Evening The analogy with a prototype declaration is exact. The declaration in the structure is a prototype declaration and like all prototype declarations is required. When the function was among its Student buddies in the class it wasn t necessary to include the class name with the function name the class name was assumed. When the function is by itself the fully extended name is required. It s just like at my home. My wife calls me only by my first name provided I m not in the doghouse . Among the family the last name is assumed. Outside the family and my circle of acquaintances others call me by my full name. Include files It is common to place class definitions and function prototypes in a file carrying the extension .h separate from the .cpp file that contains the actual function definitions. The .h file is subsequently included in the .cpp source file as follows. The include file is best defined as follows class Student public int .