C ++ object-oriented classes and objects

The end of the period, to sum up the above teaching knowledge

 

Chapter nine

9.1 class declaration

1. At the same time members of the class declaration to declare access the properties of the member.

The only difference 2.C ++ structures and classes: struct members access property defaults to the public, class members to access property defaults to private.

3. General will have to be designed as part of the external public, you do not have external members of the design as a protected or private.

4. Class member functions for all data members of the same class have the ability to access unlimited.

9.2 The basic spatial objects

5. Create an object means that the memory space allocated to the object.

6. We will space the sum of non-static data members of the object called basic space occupied by the object.

9.3 Object of self-expression

7.this point is locked can not be changed.

8. const member function is a member of the class, the form of the implicit function of this parameter const pointer constant (const * const this) of this object, it can only be read but can not modify any of the properties of this object function in vivo

9. const object can only call const member functions.

10. among all classes without modifying object attributes member functions are designed const member functions are beneficial.

 

9.5 class template with a template class

11. The function template is - at the source code level, and the pending data manipulation functions described type determined

Look at an example of a two-dimensional vector template:

template <typename TYPE> template class declaration class Vec2 // TYPE wherein the data type is determined, or as in the form of a data type

12. The template member function in the class declaration describes vitro when writing format:

template <typename TYPE> TYPE representation showing the template data type "template name <TYPE>" template full class name (with the form data type class name)

 

Guess you like

Origin www.cnblogs.com/joelovescoding/p/11829505.html