C + + Summary of knowledge net

Source: Internet
Author: User

Rice teacher often said a word: construct knowledge network.

Take the exam now. Let's construct a knowledge network that belongs to C + +. First, learn about C + + in general:

To be able to understand, there are five main parts. And when we relate to the previous knowledge, there are templates and operator overloads and some of the features in the base. How do you say that?? Function in VB to learn some. Some of the bases and inspirations, arrays and pointers have been learned in the introduction to data structures, so this is not a difficult part.

So that's what it looks like. C + + is not as hard to imagine as it is. The review will not be a flying blind. First look at a specific diagram:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvwvndmteymw==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

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 a random keyword.

distinguishes between uppercase and lowercase.

2.< functions >

1) Prototype : The default value problem that does not involve a parameter is simply a declaration type.

2) Pure virtual functions and virtual functions : both use Virtualkeyword. But the difference is. A subclass of a virtual function can inherit a parent class without overriding it, and can be overridden. The Zorie of pure virtual functions must be rewritten enough to be used.

On the other hand, as this code shows: virtual void show () =0 is pure virtual function, and the definition of virtual function named Show does not need to use "= 0";

3) strcpy: copy constructor, form reference. At the same time you must use the keywordconst of the constant member function in order not to change the value of the shape.

There are three scenarios for using this function:

• You need to create an object in the program and instantiate it with an object

• The function's parameter 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 a member function and a constructor call;

5) Const: It is used to qualify a variable that does not agree to be changed. The object declared by the qualifier can only be read without being altered, and the constant object must be initialized when it is defined. 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). is not a member function of the current class. It is an external function independent of the current class.

function names and types, such as DateTime (D,T), can be used directly when used in the body of functions. And you don't have to add "class name::" As a member function 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 + +, the user is not agreed to customize the new operator. Only the existing C + + operators can be overloaded, and the operators that cannot be overloaded have only 5 (. ,. *, *,::,? :)

A function that overloads an operator cannot have a default number of parameters, and the overloaded operator must be used with the user-defined object of its own definition type, and does not agree that all the parameters are standard C + + types.

2) function overloading

A function overload must be a different type of parameter or a different number of parameters, rather than relying on a return value type to differentiate overloaded functions.

PS: Overrides and overloads differ:

* overloads must be in the same class. The method name must be the same. And the list of references cannot be the same.

* Overrides are in different classes. The two method return values, method names, and list of parameters that are overridden must be fully consistent. The access level of a subclass method must not be lower than the level of access to the parent class's corresponding method. Method body is different.

In today's share, VB, C # and VB.net have been learned, only to slowly hair today's programming language resonance. There are similarities between these programming languages. Just like human beings, they have their own unique side. Then it's enough just to figure out what's different about them. Maybe this is my knowledge net.

C + + Summary of knowledge net

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.