My C ++ notes (class and object) and notes object
/** Main. cpp ** Created on: 2015-7-24 * Author: feiruo * // ** class and object: ** 1. abstract: * abstraction in Object-Oriented Methods refers to the process of generalization of specific problems or objects, extracting and describing the public properties of a class of objects. * Data abstraction: Describes the attributes or States of a certain object, that is, the characteristics of such objects that are different from those of other objects. * Behavior Abstraction: describes the features of common behaviors or functions of a certain object. ** 2. encapsulation: * encapsulation combines abstract data with behaviors or functions to form an organic whole, that is, the organic combination of data and Function Code of operation data. Form a class, where data and functions are members of the class. ** Class Clock {public: void setTime (int newH, int newM, int newS); void showTime (); private: int hour, minute, second ;}; ** 3. inheritance: * The class Inheritance Mechanism in object-oriented languages allows programmers to provide more detailed description on the basis of maintaining the original class features. ** 4. Polymorphism: * broadly speaking, polymorphism refers to the ability of a program to process multiple types of objects. In the C ++ language, this polymorphism can be achieved through forced polymorphism, heavy load polymorphism, type parameterized polymorphism, and inclusion polymorphism 4. * Forced polymorphism is implemented by converting one type of data to another type of data. Overloading means giving different meanings to the same name. Including polymorphism and shape parameterization polymorphism are common polymorphism and are true polymorphism. ** 5. Class Definition: * in Object-Oriented Programming, program modules are composed of classes. Class is the encapsulation of logically related functions and data. It is an abstract description of the problem. * Class name {public: // external interface; private: // private member; protected: // protected member;}; ** 6. object: * class is an abstract mechanism that describes the common attributes and behaviors of a class of things. A class object is a specific entity of the class (instantiated ). * General Method: * class name Object Name; ** 7. class member functions: * (1) Implementation of member functions: * The prototype Declaration of the function should be written in the class body. The prototype describes the parameter table and Return Value Type of the function. The specific implementation of functions is written outside the class definition. Different from common functions, you must specify the class name when implementing a member function. The specific form is: * return value type Class Name: function member name (parameter table) {// function body;} * (2) objective object in a member function call: * The difference between calling a member function and calling a common function is that you need to use ". "operator indicates the object to be called. This object is called the target object in this call. ** (3) member functions with default parameter values: * For example, void setTime (int newH, int newM, int newS) in Clock class; ** (4) inline member functions: * When a function is called, some memory resources and running time are required to pass parameters and return values. The inline function can be declared in two ways: * Implicit Declaration: * class Clock {public: void setTime (int newH, int newM, int newS); void showTime () {cout