Computer Science 1037A/B Lecture Notes - Lecture 18: Inline Function, Entire Function, Morphism Of Algebraic Varieties
Document Summary
Member functions are part of a class declaration. Entire function definition inside the class declaration or. Just the prototype inside the class declaration and write the function definition after the class. Member functions defined inside the class declaration are called inline functions. Only very short functions should be inline functions int getside() Put a function prototype in the class declaration. In the function definition, precede the function name with the class name and scope resolution operator (::) int square::getside() return side; Consider a circle class inside the class declaration the functions we place the following prototype void setradius(double r); double getarea(); Following the class declaration we will place a function implementation section containing the following function definitions void circle::setradius(double r) radius = r; double circle::getarea() return 3. 14 * pow(radius,2); Use get" in the name of accessor functions, set" in the name of mutator functions.