Data members declared in 1.private can only be accessed by member functions in public, that is, data hiding, which is encapsulated.
2. Each class has a constructor that initializes the class object when it is created, and the constructor must be guaranteed to have the same name as the class to distinguish the other
member functions, generally declared public
3. Every time an object is created, C + + requires a constructor to be called once, which guarantees that the program is initialized correctly. In any absence of an explicit
In the class that contains the constructor, the compiler provides a default constructor to initialize.
Note: When an object is created with an argument constructor defined, it cannot be created directly like the previous Gradebook Mygradebook.
Otherwise you will get an error because you have defined a constructor, so you have to create it in the form of a constructor, such as Gradebook Mygradebook ("abc");
If the constructor does not have an argument, it is defined as gradebook mygradebook; Note that there is no parentheses here.
4. The reusability of independent files, that is, we write classes may be used by other different programs, so for convenience, we can put the class and main function
Separated, where the class retains the name "GradeBook.h", which is what. h, and then if the main function is going to call it, you can start with
#include "GradeBook.h" to invoke. It is important to note that both are placed in the same directory.
5. Declaration of class, implementation and separation of main function: declaration is saved as. h file, the same name is saved as CPP, the main function call directly
Call "GradeBook.h". Note that it is implemented with Gradebook::
The validity of the 6.set function can guarantee the validity of the incoming parameters, such as Setcoursename () if the name is guaranteed to be within 25 characters,
Then it can be handled in the SET function.
Basic Learning notes like C + +