interview C language Essence
1, process-oriented : Analyze the steps required to solve the problem, and then use the function to take these steps step by step implementation.
Object-oriented: directly describes the object of the objective world and its interrelationship. Any entity in the real world can be seen as an object, and objects interact with each other through messages, using object-oriented programming, we only care about excuses, not how to implement.
2 . Three features of C + + : inheritance, encapsulation, and polymorphism.
Inheritance: An object directly uses the properties and methods of another object. Inheritance allows subclasses to have various properties and methods of the parent class without having to write the same code again.
Encapsulation: On the program, hides the object's properties and implementation details, only exposes the interface externally, and controls the access level of the property's read and modify. The goal is to enhance security and simplify programming.
Polymorphism: Interfaces are implemented in many different ways. The same action can have different interpretations on different objects and produce different execution effects.
3.sizeof
is an operator that is used to determine the type of data and the length of an expression. The calculation of the number of bytes is done at compile time.
Sizeof (type specifier, array name, or expression)
4. typedef: Used to define simple aliases for complex declarations. It is itself a keyword for storage classes.
Typedef int newname:
#define: Macro definition is also called macro substitution, macro substitution. One of the three preprocessing functions, and the other two are file inclusions and conditional compilation.
5.enum:
Enumeration types, in real-world problems, the range of values for some variables is limited to a limited range. To illustrate these quantities, a new data type is introduced.
6,Struct,class constructor Understanding :
The most essential difference between struct and class is the default access control: struct defaults to public, and class defaults to private. struct: struct type, used to hold a different data type. Class: Classes are the basic unit of the construction program.
7,static: keywords.
Declares static variables, which are stored in static memory. Role: Keep variables persistent and hidden. A static local variable is first initialized when the program executes to the declaration of the object, and subsequent function calls are no longer initialized. 8, Const: keyword. It restricts a variable to be allowed to be changed. Function: To some extent, the security and reliability of the program can be improved. There is also some help in understanding the program for others. At the same time, the parameters can be easily adjusted and modified.
9,C, and C + + Memory allocations:
(1) Allocation from a static storage area. Memory has been allocated at the time of program compilation, and the existence of the program during this period of operation exists.
(2) Create on the stack. It is automatically assigned and freed by the compiler when the function is executed.
(3) dynamic memory allocation. Assigned by the programmer himself, the program is run with malloc or
New applies any byte of memory, which is then the responsibility of the programmer to free up memory with no or delete . The life cycle of dynamic memory is determined by programmers and is more flexible to use.
Char *p;p= (char*) malloc (size);
Free (p):
int *p=new int; ...
Delete p;
10, pointers and references : Reference: A reference is an alias for a variable, the operation of the reference and the direct manipulation of the variable
Exactly the same. Inta; int & ra=a; defines the reference RA, which is a reference to variable a .
Difference:
(1) A reference cannot be null, and the pointer can be empty.
(2) The reference can not be changed to point, the pointer can be changed to point. (3) The size of the reference is the size of the variable that is pointed to, and the pointer refers to its size. (4) A reference is only an individual name, and the pointer is an entity.
The return value of the function:
A function can have only one return value, and a function that has more than one return value may use pointers or struct-body variables.
andextern:
Declare an external variable or function that defines the definition of a variable or function in another file, prompting the compiler to find its definition in other modules when it encounters this variable or function.
char*p=,"SDFSDF"; This method initializes the constant string, so p cannot modify the contents of the string.
Char p[]= "SDFSDF";
p= "SDFSDF";
Char p[]= "SDFSDF";
Both of these are variables that can be modified.
The pointer occupies 4 bytes under a 32-bit system .
< Span style= "FONT-SIZE:12.000000PT; font-family: ' Timesnewromanpsmt '; Color:rgb (100%, 0%, 0%); " > 14 array name and pointer
The array name is not a pointer, and the array name represents the address of the first element of the array, which is a constant.
The pointer holds the address of a variable, which is itself a variable.
the pointer function and function pointer :
- Pointer function: A function in itself, a function that returns a pointer to a type. Function pointer: itself is a pointer to the address of the function to hold. function pointers: One is to achieve polymorphism in object-oriented, and the second is callback function .
synchronous vs. asynchronous:
- Synchronous: When a function call is made, the call does not return until the result is obtained.
- That is, one thing has to be done, so that the next thing can be done after the first one is done.
- Async: When a function call is made, the caller cannot get the result immediately. Actually deal with this
- Called by the State, notification, and callback to notify the caller when a part is completed.
file operations
File *FP: fp=fopen ( filename, using file mode ); ..........
Fclose ();
iOS Development--Interview the C language essence