Basic knowledge of C + + easy to summarize (backlog)

Source: Internet
Author: User
Tags class definition

=======================================================================================

1. In C + +, the operators that cannot be overloaded are:sizeof,. Member operator ,* dereference operator ,:: scope operator , and ?: conditional operator !

2. C + + language polymorphism is divided into: compile-time polymorphism and run-time polymorphism, where compile-time polymorphism can be achieved through function overloading and template implementation, runtime polymorphism through virtual function!

The mechanism for implementing runtime polymorphism is called dynamic binding!

3. About the header file reference method:

    • #include <> allows the compiler to search only the system directory, not the local directory; the header file you write with <> will report an error!
    • #include "" The compiler first searches the local directory, if the local directory does not search the system directory, if the system directory is placed in the current directory, the reference "" can be used preferentially;
4. Set A, B, C, D, M, n are int variables, and a=5, B=6, c=7, D=8, m=2, n=2, then the logical expression (m=a>b) && (n=c>d) operation, the value of n is?

parsing: operator precedence and && usage rules, = priority is less than the qualifier > < so,&& left m=0, false does not execute right expression, so the value of n does not change to 2!  

5. Overloaded function refers to the same function name can correspond to the implementation of multiple functions, the compiler will automatically call the corresponding function according to the number of parameters, parameter types, and note that the function return value type cannot be used as an overloaded judgment condition!

6. If the friend function overloads an operator, the argument list is 1, the description is 1, the 2 description is 2, and if there is no argument the overload is wrong! If the member function overloads an operator, no parameter is 1, and 1 parameters are 2 yuan;

7. Questions about circular statements:

    • The Do-while loop can be written as a while loop, and the loop body executes at least once;
    • while (condition false), the loop body does not execute;
    • The break statement can be used in the loop body to jump out of the nearest loop statement;
    • Continue can only appear inside the for/while/do while loop, or inside statements and blocks nested within such loops, and cannot be used in a separate switch continue;
8. About Constructors:
    • Neither the default constructor nor the copy constructor has a return value!
    • The parameters of the copy constructor can make one or more, but the first must be the reference object of the Class!
    • If the copy constructor is not declared in the class definition, the compiler will automatically generate a default copy constructor, but it will not be a protected member of that class!
    • The purpose of the copy initialization constructor is to copy the data member values of a well-known object to another homogeneous object being created!
 

Basic knowledge of C + + easy to summarize (backlog)

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.