C / C ++ written examination basics

1, int * a [10]: int type pointer points to the array a [10]

  int (* a) [10]: 10 points to an array of type int pointer to a

  int (* a) (int): a function pointer to a function that returns the type and parameters of both int

  int (* a [10]) (int): array of function pointers, pointing to a parameter and returns an array of type int are

 

2, C ++, a derived class can be inherited function is a member

 

3, char * p () function pointer, a function

   char (* p) () function pointer, a pointer

 

4、union test

{

  int x; char y; float z;

}

  Joint size is 4 bytes, because the Commonwealth size is determined by the maximum size of a member

 

5、int a = 0; int b =(a = -1) ? 2: 3;

      int c = (a = 0)? 2:3;

   Since b = -1, non-zero, is true, so that b = 2, c = 0, zero, false, so c = 3

 

6, the constructor must initialize the list of three cases of initialization:

  1) need to initialize the data members of the object;

  2) need to initialize const modified class members;

  3) need to initialize a reference member data.

 

7, VirtualAlloc is WinAPI function, function: the calling process virtual address space, scheduled or submit some pages.

  MEM_RESERVE reserved address space, not physical memory allocation.

  PAGE_READONLY when trying to access the page area, it will be denied access.

  PAGE_NOACCESS any access will be denied.

 

8, C ++ function is only defined in parallel, the definition can not be nested, but statements can be nested. And in C ++, the main function of the position can be anywhere.

 

9, X & (X-1) count the number of X 1,

   X | (X-1) Statistics X number of zeroes. (X is binary)

 

10, main parameters in function char * argv [] is equivalent char ** argv, i.e. char * s [] is equivalent to char ** s.

 

11, member functions when operating two objects, just pass an object parameter, and the other is to call a member of this, friend function takes two parameters objects.

 

12, the advantage of the dynamic link library: good sharing, development model, reduce page swapping

   Advantage of statically linked libraries: load faster

 

13, malloc: stdlib.h header file needed; return value is a pointer.

   In C, you do not need to use malloc cast, in C ++ required cast.

 

14, reference is applied by an alias variables

 

15, the base class and a derived class function type with abnormal function return value must match the specifications

 

16, static members can be used as a default argument, non-static member can not serve as the default argument. When the function is called, began to occupy the internal variable storage unit

 

17, the partition ## is a connection, the role: first partition, and then forced connection

 

18, the internal static class variables Inconsistent visibility and presence. Existence: life cycle; visibility: refers to access to the internal static class variables

 

19, the X-++ only as the right value , but ++ x either as a left value, can also be used as the right value

 

20, char data [0] of the flexible array, also known as variable length arrays. As there is only a symbolic address, and must be the last member of structure

 

21, the thread has its own stack, the stack, so the variables other than the local variables need to be set to protect local variable storage

 

22, private member, class member functions provided they can be used directly, a friend function also can use them directly.

 

23, post-order traversal sequence: sequence left, right, root, preorder traversal of: root, left and right

 

24, binary search time complexity is: O (nlog n)

 

25, the n-th ordered sequence inserted in a new element of the table, and keep constant the original order, the average number of elements to be moved is n / 2

 

26, the n different sort of data to be exchanged, at most need to compare the n (n-1) / 2 times

 

27, the algorithm has zero or more inputs, having at least one or more output

 

28, e / E must be in front of the array, followed by an integer.

 

29, printf with specifier% 5s, if the length is greater than the actual length of the string, the output according to the actual length,

             If the string length is smaller than the actual length, it is right-aligned output, fill the space left.

 

30, a + 7 only as the right value, i.e. the same as x ++ only as the right value.

 

31, reference is another means may be produced in addition to the effect of polymorphic pointer. It means a reference to a base class can point to its derived class instance.

 

32, priority: ~, <<, &, ^. (From left to right priority order)

 

33, a preorder traversal: the root node first row, and first left and right sibling

   Preorder: first the left, then the root node, and finally the right

   Postorder: first left, rear right, and finally root

 

Guess you like

Origin www.cnblogs.com/zonkidd/p/11729502.html