0828 Trend

Article Directory

Others

Author: mango, Ernie sauce
link: https:? //Www.nowcoder.com/discuss/490721 type = all & order = time & pos = & page = 1 & channel = 666 & source_id = search_all
Source: Cattle-off network

On the one hand, 2020.08.27,
an uncle, at least 20 years of development experience, smiling
1. Self-introduction
2. Three object-oriented features:
encapsulation, inheritance, and polymorphism

  • Encapsulation: Enclose the data object and the implementation process, and access to its internal data can only be accessed through the interface, which can reduce the coupling.
  • Inheritance: The child class inherits the parent class, and the child class can rewrite and expand the method of the parent class. The disadvantage is that it improves the coupling of the code. If a class is defined with the final keyword, then the class cannot be inherited, and the internal methods of the class cannot be overridden or expanded
  • Polymorphism: Base class pointers or references can point to objects of different derived classes and react differently to the same message. Polymorphism is implemented using virtual functions

3. The difference between a virtual function and a pure virtual function. The
virtual keyword is added before the definition of a virtual function. The virtual function is a
pure virtual function designed to achieve polymorphism. The virtual keyword is added in front of the declaration, followed by 0. A class only provides an interface, not a specific implementation method. If you want to define it, you can only define it outside the class. The specific implementation method is handed over to the derived class to implement. A class containing pure virtual functions is called an abstract base class; an abstract base cannot be defined For the object of the class, the pure virtual function must be rewritten in the derived class of the abstract base class, otherwise the derived class is still the abstract base class.
Usage scenario
4. Can the constructor and destructor be virtual functions?

  • The constructor cannot be a virtual function
    1. Consider from the perspective of storage space: a virtual function corresponds to a virtual table, which is stored in the storage space of the object, but when the constructor is called, the object has not been instantiated and has not been stored yet Space, so the virtual function cannot be called, so it is said: the constructor cannot be defined as a virtual function
    2. From the perspective of use: the virtual function is realized by calling the virtual function when the base class pointer or reference points to the object of the derived class The call to the function defined in the derived class, and the constructor is automatically called when the object is defined, so there is no need to define it as a virtual function.
    3. From the point of view of implementation, the virtual table is created after the constructor is called, so the constructor cannot be defined as a virtual function
    . 4. When creating an object, the type of the object must be clear, unlike the virtual function until the program is running To determine the type of object pointed to
  • The destructor function can be a virtual function. If there is class inheritance, the virtual function must be defined as a virtual function in the base class:
    the destructor function is defined as a virtual function to avoid memory leaks, when the pointer of the base class object points to the derived function For class objects, when the object is destructed, if the destructor function is not defined as a virtual function, only the members in the base class can be deconstructed, and the unique members in the derived class will not release the memory, thus causing memory leaks.
    5. The osi seven-layer model, focusing on the https and http
    physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer
  • http: Hypertext Transfer Protocol is currently the most widely used communication protocol on the Internet. It is the standard for client and server requests and responses, and is used to transfer hypertext from the server to the local browser.
  • https: On the basis of http, it increases the security of transmission and adds the ssl layer, which means that it is composed of http+ssl layer. When the client and the server establish a connection, the ssl connection is first established
  • The difference between the two:
    1. Transmission content: http transmits plain text, https transmits cipher text
    2. The connection method and port number are different, the default port number of http is 80, and the default port number of https is 443. The http connection is very simple and stateless. https is a network protocol composed of http+ssl that can be used for encrypted transmission and identity authentication.
    3. https needs to apply for ca (Certificate Authority) certificate.

6. The difference between mysql and redis

  • mysql is a relational database, redis is a non-relational database using key-value storage method, cache database
  • MySQL is a persistent storage of data in the disk, powerful, supports sql statements and transactions, read and write speed is slow; redis is frequently stored data in the cache, read and write speed is very fast

7, mysql connection pool
In the process of using the database, when there are frequent connection establishment and disconnection operations, the performance of the system will be greatly reduced. Therefore, the idea of ​​resource pool is used in the database to avoid frequent allocation and release of resources, and connection pool appears. So that when a connection is established, the database connection can be obtained by calling the getConnection() method, and when the connection is released, the connection pool can be recovered by calling the releaseConnection() method.
Benefits of connection pool:

  • Resource reuse: database connections are reused, avoiding frequent connection establishment and connection release operations, improving system performance and enhancing system stability.
  • Improve response speed: When the connection pool is initialized, a number of database connection operations are established. When a business requests a database, a series of initialization operations when establishing a connection is avoided, which can improve system performance
  • Avoid connection leakage: When the occupied time is exceeded, the connection pool will recover the occupied connection, avoiding the leakage of connection resources

8. Clustered index and non-clustered index
Clustered index: the order of the index and the storage order of the data are the same, if you take the Xinhua dictionary for example, the pinyin directory is equivalent to the clustered index
non-clustered index: the order of the index and the data The storage order is different, and
the conditions and problems of index creation are
suitable for index creation:

  • Primary key to create a unique index
  • Indexes can be created when the amount of data is very large
  • Columns often used as where query conditions can be indexed
  • Columns used for grouping index

Not suitable for index creation:

  • Small amount of data
  • The number of values ​​corresponding to the attribute is evenly distributed
  • Tables that are frequently inserted and deleted
  • Fields not used as query conditions

9. The realization of virtual memory
only put part of the program in the memory, so as to obtain a memory that runs larger than the physical memory, realize the exchange of memory and external memory, and obtain a larger memory space.
Virtual page storage
Virtual segment storage
10. Process communication methods
Signals, pipes, message queues, shared memory

  • Pipe: Pipe is a half-duplex communication method. Data can only flow in one direction and can only communicate between parent and child processes (anonymous pipe); named pipe FIFO can communicate between processes that are not related.
  • Signal: A signal can be sent to a process at any time without knowing the state of the process

11. Thread safety implementation reference: Click on the link.
Thread safety : In a program that has multiple threads executing in parallel with shared data, thread-safe code will ensure that each thread can be executed correctly through a synchronization mechanism without data pollution.
How to ensure thread safety:

  • Lock shared resources to ensure that each resource variable can only be occupied by one thread at any time
  • Let the thread also own resources, instead of sharing the resources of the process, that is to say, maintain a private local variable for the thread

12. Asked a little paper question.
13. Introduced the trending business
and some stack security, debug and release issues, which
benefited a lot.

Two sides
1. Project introduction
2. C++ asked a lot of questions. . .
What's more, the question is not the basic questioning method. It is all about asking questions in a different way and setting.
I was asked to wear it!
It involves static (ordinary functions will push a this pointer, so static member functions
cannot access ordinary member variables), virtual functions, linux file attributes,
linux namespace
mutex and critical section
hiding, overloading, and rewriting
3. socket Programming
Details of the three-way handshake
Hey, the foundation is still not solid. . .

Three sides:
1. No self-introduction
2. Project && paper
3. Three major features
4. Virtual usage
Principle of diamond inheritance
5. Database index mechanism
6. I wrote a SQL statement
7. The relationship between redis and mysql
8. Browser Can’t open the webpage. How to ping the
dns server
(localhost)
. The configuration of tcp.
9. The difference between copy constructor and assignment.
10. Two small algorithms. Oral
reverse Polish expression.
Longest palindrome substring.

15:45-18:46
I am so stupid. . . . Find an oc

Replay

one side

  1. Introduction project
  2. C++ static usage scenarios
  3. Singleton mode, how to realize the hungry man mode
  4. How to achieve polymorphism? Keyword
  5. Why is the destructor defined as a virtual function
  6. Which containers in STL have learned
  7. The underlying implementation of vector, push_back element, what will happen to the memory
  8. Set, insert 10 integers in the set, what is the order of the integers when traversing, and the time complexity of inserting n elements in the set

Two sides

  1. Quick sort, introduce quick sort, how to select dividing points
  2. Red-black tree, application scenario
  3. 8 balls, 7 of which have the same weight, one of them is the heaviest. You can find the heaviest ball by comparing at least several times
  4. New features of c++11
    13. Smart pointers, what problems will using smart pointers bring? How to solve?
  5. How to achieve polymorphism
  6. Run-time polymorphism and compile-time polymorphism, how is compile-time polymorphism achieved
  7. Process communication method
  8. https handshake process, encryption method
  9. Ask the project, what problems will occur during the operation of the neural network, over-fitting and under-fitting? The difference between rnn and lstm

Three sides

  1. http, and tcp protocol
  2. https protocol,Whether http is stateful or stateless, dig into this statelessness
  3. http https
    21.When ttps establishes a connection, it will establish a session key, and then use the website's public key to encrypt the session and transmit it to the website. Will it be hijacked during the transmission? How to prevent this phenomenon from happening
    22.The difference between ookie and session
  4. char * a = "dddd"; and char a[] = "dddd"; How much memory space these two variables occupy, where the variables are stored, and where "dddd" is stored
  5. C++ polymorphism usage scenarios
  6. static_cast, reinterpret_cast, dynamic_cast的区别
  7. Use scenarios for merge sort
  8. Preemptive scheduling and non-preemptive scheduling, which scheduling method for windows system (preemptive scheduling)

Guess you like

Origin blog.csdn.net/qq_31672701/article/details/108268791