Rice teacher often said a word: construct knowledge network. Immediately to the test, let us construct a knowledge network belonging to C + +. The first step is to understand C + + as a whole:
As you can see, there are mainly five parts, and when we relate to the previous knowledge, there are templates and operator overloads and some of the features in the foundation. How do you say that?? Function in VB to learn some, some base and inspiration, arrays and pointers in the "Introduction to Data Structure" in the study, so this part is not a difficult point. Then in this way, C + + is not as difficult as imagined, review will not be a flying blind. First look at a detailed diagram:
As shown in the figure, we still have to pay attention to the following points:
1.< identifiers >
the underscore or letter begins;
Cannot have the same name as any of the keywords;
Case sensitive;
2.< functions >
1) Prototype : The default value of the parameter is not involved, only the declaring type.
2) pure virtual and virtual functions: Both use the virtual keyword, but the difference is that the subclass of the virtual function can inherit the parent class without overriding it, or it can be overridden. The Zorie of pure virtual functions must be rewritten before they can be used. On the other hand, as the code shows: virtual void show () =0 is a pure virtual function, and a virtual function named show does not need to use "= 0";
3) strcpy: copy constructor, formal parameter is a reference, and in order to not change the value of the formal parameter must use the constant member function keyword Const.
There are three scenarios for using this function:
• You need to create an object in your program and instantiate it with another object
• The function's argument is the object of the class
• The return value of the function is the object of the class
Note: When you use this function to assign a value string, you can assign a value to the direct use of the double, int type "=".
4) Template : symbol <t> Use the identifier "<T>" for both the member function and the constructor call;
5) Const: It is used to qualify a variable that is not allowed to be changed, and the object declared by the qualifier can only be read without being modified; The constant object must be initialized at the time of definition and cannot be updated.
6) inline: inline
Note: Macro functions have a preprocessor to replace macros, and inline functions are implemented by the compiler.
7) Friend : (friend), not a member function of the current class, but an external function independent of the current class. When used in the body of a function, you can directly use function names and types, such as DateTime (D,T), and do not add "class name:" In the same way as member functions when declaring externally.
8) Recursion : As the introduction to data structure says, a function invokes itself in the body of a function.
3.< Heavy Duty >
1) operator overloading
In C + +, users are not allowed to define new operators themselves, only overloaded with existing C + + operators, where operators cannot be overloaded with only 5 (. ,. *, *,::,? :)
A function that overloads an operator cannot have a default argument, and an overloaded operator must be used with an object of a user-defined custom type, and the parameter is not allowed to be all standard types of C + +.
2) function overloading
A function overload must have a different type of argument or a different number of arguments, rather than relying on a return value type to differentiate overloaded functions.
PS: The difference between overriding and overloading:
* overloads must be in the same class, the method names must be the same, and the argument list cannot be the same.
* Overrides are in different classes, where overridden two method return values, method names, and parameter lists must be exactly the same. The access level of a subclass method cannot be lower than the access level of the corresponding method of the parent class;
Mixed to the present, VB, C # and VB.net have learned, only slowly found in the programming language of the resonance, these programming languages have similarities, and just like humans, have their own distinctive side. Then it is enough to make sure they are different. Maybe this is my knowledge net.
C + + Summary of knowledge net