C ++ programmer interview notes (2)

Source: Internet
Author: User

1. Introduce STL. How does STL implement vector?

STL is composed of containers, algorithms, and iterators. Advantages: 1. Easy to perform a series of operations on data: sorting, searching, inserting, adding, and deleting. 2. Convenient and secure debugging programs 3. cross-platform debugging.

Vector is essentially a dynamic array, which will expand its space Size Based on the increase of data.

2. relations and differences between Polymorphism and inheritance: the basis of polymorphism is inheritance. Without inheritance, there is no polymorphism.

3. pointer reference? Reference is efficient with pointers and convenient and intuitive to use variables. The reference must be initialized and cannot be blank. It will not be changed once initialized.

4. How many data transfer methods? 1. Transferring different values (copying objects) will not change the original data, but big data will consume memory and time. 2. pointer transmission (Address Transmission) can change the original object. Fast 4. Reference transfer: the same value is used, but the effect is indeed a pointer effect. C ++ recommends that we use references to replace pointer passing. We can use const &. To pass the value.

5. Design Pattern concept: the design pattern focuses more on expansion and reusability.

6. Design Pattern: it is a specific method to solve a specific Object-Oriented Software problem. We use this design pattern to solve similar problems: instead of having to design a solution again.

Differences between the design mode and the framework: 1. the design mode is designed for solving object-oriented problems, while the framework is designed for specific businesses. 2. The design pattern is more abstract, and the framework can be represented by code. 3. The framework can contain multiple design patterns. The framework is a semi-finished product. Through the framework, we can improve efficiency and reduce repetitive and monotonous work.

7. Differences between C and C ++: Structure in C: only a set of data. Structure in c ++: class features. In C, struct must be added before the structure variable. C ++ does not.

8. The constructor cannot be a virtual function: because the existing parent class has sub-classes and the object does not come out, how can we call the method. The Destructor can be either a virtual function or a pure virtual function.

9. Polymorphism: 1. Function overloading 2. The template uses 3 virtual functions. What is the inheritance relationship between subclass and parent classes? The child inherits most of the parent's resources. Only constructors, destructor, and copy constructors are supported. Operator = 4 functions cannot be inherited, and a friend function is added. It cannot be inherited.

10. Why do we need to enter the abstract base class and pure virtual functions? The purpose is to achieve an interface effect. To better represent the objective world.

1. Introduction to the template: it embodies a general and generalized programming idea. 7 containers: vector list deque map set multimap Multiset stack queque qro ...... queue.

2. MVC: Model View contrler model layer (specific class entity), view layer (user operation layer), control layer (business logic processing code layer) Dao layer.

3. How many Process Synchronization examples are provided ?!! 215

4. Process deadlock: a process in which multiple processes have resources and want other processes. Mutual requests cannot meet the conditions for releasing resources. Deadlock

5 ......... At the beginning of Question 215, it was a knowledge point of the process. I 'd like to take a look at it more.

 

6. Differences between static and non-static members of a class: 1. There is only one static member, and all such objects are shared. You can call the class name to obtain a non-static member. 2. Each object has its own copy. Object. Operator

7. Differences between arrays and linked lists: Fixed Array sizes, sequential storage, variable linked list sizes, and random storage. Flexible. But it is more difficult to manage than array.

8. memory Allocation: 1. static storage area (Global Area: BBS segment (a memory space initialized to 0): global variables and static variables. there are 2. STACK: local variable. The function is automatically released after it is completed. 3. Heap zone: Global. The program uses malloc new free Delete to open up and release space, which is flexible, but there are many problems. We need to manage and manually allocate space to manually release space.

9. The role of polymorphism: 1. Hiding Implementation Details 2. Reusing interfaces to provide unified external interfaces.

10. Difference Between New Delete malloc free: New Delete will call the constructor and destructor, while malloc will not initialize the object free and will not call the destructor of the object.

11. Static function: 1. restrict the scope of the variable 2. Set the storage domain of the variable.

12. What is the cause of stack overflow? 1. Unconditional recursion. 2. The use of big data structures leads to insufficient stack space. 3. The Spam resources are not recycled, resulting in Memory leakage and eventually exhausting the memory.

13. INT (* s [10]) (INT) This is a function pointer array: Each Pointer Points to an int func (int ppp) function.

14. extern "C" is a connection Declaration: variables and functions modified by extern "C" are compiled and connected in C voice mode.

You can add the code written in C language to the C ++ project. Xi

15. strcpy mechanism: assign a value to the address space starting with the SRC address and containing the null terminator to the address space starting with the DeST. If there is no Terminator, the number of characters in copy is unknown.

16. Pass the pointer as a parameter to a function with the shape parameter as a pointer. Even if the pointer malloc is provided inside the function, the real parameter malloc is not given. So pay attention to this trap. Because the pointer value is equivalent to the value. Unless the value address is assigned to the pointer, It is similar.

17. Implementation of strcpy:

Char * strcpy (char * strdest, const char * strstc ){

Assert (strdest! = NULL) & (strstc! = NULL ));

Char * adress = strdest;

While (* strdest ++ = * strstc ++ )! = '\ 0 ');

Return address;

}

18. Implementation of strlen:

Int strlen (const char * Str ){

Assert (strt! = NULL );

Int Len;

While (* STR ++ )! = '\ 0') {Len ++ ;}

Return Len;

}

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.