[C/C++ Basic Exercises] Review Question 3, Notes on Error-prone Knowledge Points

 C++ review question knowledge point records:

Identifier naming rules: it cannot be a keyword, it can only be composed of letters, numbers, and underscores, and the first one cannot be a number .

The meaning of data type: allocate appropriate memory space to variables

Integer: short short 2 long long 4/8 long long long long 8 The difference is that they occupy different memory spaces

The memory size occupied by the sizeof() type

Real type (floating point type) float 4 7 significant figures double 8 15-16 significant figures

Character type char is used to represent a single letter 1 byte, put the corresponding ASCII code into the storage unit instead of the character itself

String type char variable name [ ]="string value" If [] is C language style, if not it is C++ style

Escape character: /t horizontal tab, occupying eight positions, aligning the following

Boolean type bool only occupies 1 byte size true 1 false 0

In the division operation, the division of two integers is an integer, the division of two decimals is not a decimal, and the division is an integer.

In the modulo operation, only integers can be moduloed, not decimals.

 nested if

 switch

while

while(1) loops all the time, pay attention to avoid infinite loop

do while

When defining a structure type, it is not possible to set default values ​​for members.

When sharing a common variable. The principle for the system to allocate storage space for it is to allocate the member with the largest memory space

a' ,L'a', "a", L"a" char long char string long string

The Boolean type has only two values ​​false--false essence is 0, true--true essence is 1, occupying only one byte size

A function can be declared multiple times, but defined only once.

The pointer size is 4 bytes under 32 bits, and 8 bytes under 64 bits.

Reference syntax: data type & alias = original name.

int * a = new int (10);delete a;

int * arr= new int [10];

for(int i=0;i<10;i++)

{

  arr[i] = i+100 //Assign 100~109 to 10 elements

}

delete [ ] arr; //Release the array must add a square bracket in front of this pointer

In the C++ language, the most basic data types include: integer, real, and character.

The break statement can only be used within the body of a loop or switch statement 

When declaring a function, the formal parameter name can be omitted, but the type and number of formal parameters cannot be omitted

The body of the loop does not have to execute at least once

A class is called an abstract class if it has at least one pure virtual function

The access rights of the members of the base class will change in its derived classes

Allows friend functions to access private members of the class

The private members of the base class are invisible to the derived class, that is, they cannot be directly accessed

One of the differences between a variable reference and a pointer variable is that once the reference relationship is established (after initialization), it cannot be changed, while the pointer can usually change its pointing.

Text files are sequential access files and cannot be read and written randomly. Only binary files can be read and written randomly.

The correct expression to judge whether the char variable n is a lowercase letter is ( D ).

A)’a’<= n <=’z’                   B)(n>=a)&&(n<=z)

C) ('a'>=n) | |('z'<=n) D) (n>='a')&&(n<='z') Indicate the number of characters in the string constant below? 15
"who are \n you?"

 Regarding virtual functions and abstract classes, the following description is correct (A)

A) A virtual function must be a member function of a class B) A virtual function is a function without a function body

C) A class with virtual member functions is an abstract class D) Neither the constructor nor the destructor can be a virtual function

Overloading an operator cannot change the basic functionality of the operator

Among the following operators, (C) operator cannot be overloaded.

A&&    B)[ ]     C)::     D)++

  1. Already defined: char word[ ][8] = { "China", "English", "Japan", "Tailand" } ;

The correct sentence to output "English" in word with a cout<< statement is cout<<word[1] ;.     

The correct statement to use a cout<< statement to output the substring "land" of "Tailand" in word is cout<<word[3]+3;.    

  1. A compound statement is formed by putting two or more statements in a pair {} .      
  2. The declaration of an existing function template is as follows:

        template  < class T > // class can be changed to typename

T  max( T a, T b ) ; 

When the compiler processes a function call, the type T is determined by the type of the ⑤ actual parameter of the calling function .    

  1. There are classes A and B, and objects of A are embedded in B. When the object of B is about to die, the system calls the destructor, and the calling sequence is: first call the destructor of ⑥ class B   , and then call the destructor of class A.       
  2. If the new member variable of the derived class has the same name as the member variable of the base class, the member variable of the derived class covers the member variable of the same name of the base class.      
  3. It is known that the newly added member function of the derived class has the same name as the member function of the base class: if the parameter types and number of parameters of the function with the same name are the same , then the member function of the derived class overrides the function of the same name of the base class; if the parameter type and number of the function of the same name Not exactly the same, then the member function of the derived class overloads the function of the same name of the base class...     
  4. Class inheritance means that the subclass inherits the ___data member___ and ⑨ constructor    of the base class 

Regarding ASCII encoding, the following description is wrong (C)

B.0-9 codes are smaller than letter codes.
Ca-z codes are less than AZ codes
A. 0-9 or AZ or az codes are consecutive.

The difference between Da and A coding is 32 (decimal)

The following (A) are all integer constants in C++ language.
A.0xffff and 611 B.01b and 0xa1 C.986.012 and 0667 D.2e4 and 0x
The correct representation of the following octal integer constants is (B)
A) 0a0 B) 015 C) 080 D) 0x10
5. The hexadecimal integer constant representation of the following error is ( C )
A) 0x11 B) 0xaf C) 0xg D) 0x1f
 

bdad03eb84354cb6abfffb3b89cbc6c8.png
3b38fd69dee7424e9c2bf08eb9b6666d.png

Guess you like

Origin blog.csdn.net/Catherine_77/article/details/129032551