Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Activity The answer to the first round of interview questions for Tencent's C?development engineers


Jun 02, 2021 Article blog



Yesterday, the w3cschool app developer's headline shared a "Tencent C-plus", which also attracted a lot of programmers' attention.

Activity The answer to the first round of interview questions for Tencent's C?development engineers1

Here's a look at the answers to Tencent's initial face-to-face questions:

1, the difference between a stack and a stack?

A: The space on the stack is automatically allocated/released by the operating system, and the space on the heap needs to be manually allocated/released

The stack has limited space and the heap is a large free store.

The program allocates memory to variables and functions on the stack during compilation, and the delivery of function call parameters during the program run is also performed on the stack.

The difference between 2, 301 and 302?

302 redirects are temporary redirects, and search engines crawl new content while retaining old URLs. Because the server returns 302 codes, search engines think the new URL is only temporary.

301 redirection is a permanent redirect, and search engines crawl new content while replacing old URLs with redirected URLs.

3, pessimistic lock and optimistic lock awareness

Pessimistic lock: Assumes concurrent conflicts and masks all actions that might violate data integrity. P essimistic locks assume that the probability of another user attempting to access or change an object that you are accessing or changing is high, so in a pessimistic lock environment, lock the object before you start changing it, and release the lock until you commit the changes you made. The pessimism flaw is that whether it's a page lock or a row lock, locking can take a long time, which can limit access to other users for a long time, which means that the concurrent accessibility of the pessimistic lock is not good.

Optimistic lock: Assuming that concurrent conflicts do not occur, only check for data integrity violations when committing operations. O ptimistic locks don't solve the problem of dirty reading. O ptimistic locks think that the probability of other users trying to change the object you are changing is small, so the optimistic lock does not lock the object until you are ready to commit the change, and does not lock it when you read and change the object. I t can be seen that optimistic lock lock time is shorter than pessimistic lock, optimistic lock can use a larger lock granularity to obtain better concurrent access performance. B ut if the second user reads the object just before the first user commits the change, when he completes his own change commit, the database discovers that the object has changed, so that the second user has to reread the object and make changes. This indicates that in an optimistic lock environment, the number of times concurrent users read objects increases.

4, the difference between C and C

1, the new program program thinking, C language is process-oriented, and C is object-oriented.

2, C language has a standard library of functions, they are loose, just the function of the same function in a header file; T he C++ is very tightly integrated for most functions, especially the APIs in the C-language that are an organic combination of most of the APIs of the Window system and are a collective. But you may also call the API separately.

3, especially graphics processing in C+ , which is very different from language graphics. G raphics handlers in the C language are basically not able to use in C. Graphics processing is not included in the C language standard.

4. There are concepts of structure in both C and C, but in C, structures have only member variables, not member methods, and in C+ structures, they can have their own member variables and member functions. B ut the members of the structure in the C language are public and can be accessible to anyone who wants to access it; In VC, it does not have a qualifier for private.

4, the C language can write many aspects of the program, but C s can write more and better, C s can write based on doSr programs, write DLL, write controls, write system.

5, C language on the program's file organization is loose, almost all-round program processing; The organization of the files by C? is engineered, and the classification of each file is clear.

6, the IDE in C++ is smart, and some features, like VB, may be better than VB.

7, the C-pair can automatically generate the program structure you want so that you can save a lot of time. There are many tools available, such as when you join a class in an MFC, when you join a variable, and so on.

8, there are many additional tools in C, you can carry out systematic analysis, you can view the API; You can view the control.

9, debugging is powerful, and the method is diverse.