Comprehensive knowledge questions and answers

Source: Internet
Author: User
the difference between get and post in HTTPBoth get and post are methods that the browser submits data to the Web server.

Get encodes the data to be submitted in the URL, such as the Http://hi.baidu.com/mianshiti?key1=value1&key2=value2 encoding the key value to Key1,value1 and key2,value2. Restricted by the length of the URL, the Get method can transmit limited data (different browsers have different URL length restrictions, such as Microsoft IE set to 2048).
Post places the data to be submitted in the body of the request and does not appear in the URL, so there is no limit to the size of the data.

Because get encodes the data in the URL, these variables are displayed in the browser's address bar and are recorded in the server-side log. So the Post method is more secure. definition and main role of IP,TCP and UDP protocols

IP protocol is the protocol of Network layer. The IP protocol stipulates that each computer on the Internet has a unique IP address, so that packets can be forwarded to the specified computer via the router. However, IP protocol does not guarantee the reliability of data transmission.
The TCP protocol is a transport layer protocol. It shields down the disadvantages of the IP protocol's inability to transmit reliably, and provides a reliable connection-oriented data transfer up.
The UDP protocol is also a transport layer protocol. It provides connectionless transport that is not connected.

What is the difference between references and pointers in C + +. The pointer plus what limit equals the reference. A reference is not a variable, it only means that the reference name is an alias of the target variable name, it is not a data type itself, so the reference itself does not occupy the storage unit and the system does not allocate the storage unit to the reference. A reference cannot be modified once it is determined.
A pointer is a variable that needs to allocate space in memory to store the address of the object being referred to. Because the pointer is a normal variable, its value can also be changed by assigning a value.

When you define a pointer as a const, its value cannot be changed, functions and references are similar, but there are essential differences.


What's the difference between memcpy and memmove?

Both memcpy and memmove copy several characters from the source address to the destination address.
If the source and destination addresses overlap, memcpy cannot guarantee that the copy is correct, but memmove can ensure that the copy is correct.

memcpy copies count bytes from SRC to dest; wmemcpy copies count wide characters (two bytes). If the source and destination overlap, the behavior of memcpy is undefined. Use Memmove to handle overlapping regions.

Copies count bytes (wmemmove) or characters (wmemmove) from Src to dest. If Some regions of the source area and the destination overlap, both functions ensure this original source bytes in th E overlapping region are copied before being. What is the difference between a global variable and a local variable. a global variable is a variable that is accessible to the entire program, from the beginning of the program to the end of the program, and the local variables in the module (such as a function), which can only be accessed in the module, and the lifetime from the module to the end of the module.
Global variables are assigned to global data segments and are loaded when the program begins to run. Local variables are assigned to the program's stack. As a result, the operating system and compilers can distinguish between global and local variables through the location of memory allocations.


the use and function of destructors and virtual functions.

Destructors are invoked automatically by the system when a class object dies. It is mainly used to clean objects, such as to release the dynamic space of object application.
Virtual functions are referred to as virtual function in the base class. Virtual functions can be redefined in a derived class so that the same function interface can correspond to different implementations in different derived classes. When a virtual function is invoked through a pointer to a base class, the program determines which implementation to invoke based on the object the pointer actually points to.


in C + +, what is the difference between struct and class?

In C + +, if the function or variable is not indicated as the level of access permission, it is public in the struct, and in class, private. We can modify a member function of a class with static, or you can modify the member function of a class with the const (written at the end of the function that the member variable cannot be modified, not the previous representation that the return value is a constant). Excuse me: Can you use both static and const to modify the member functions of a class?


Analysis: The answer is not. When the C + + compiler implements the const member function to ensure that the function cannot modify the state of the instance of the class, an implicit argument const this* is added to the function. But when a member is static, the function has no this pointer. This means that the static usage and static are conflicting.


We can also understand that the semantics of the two are contradictory. The role of static is to indicate that the function only acts on static variables of a type and is not related to instances of a class, and that the const function is to ensure that a function cannot modify the state of an instance of a class, and is not related to a static variable of a type. Therefore, they cannot be used at the same time.
static member functions can also be virtual functions.


Analysis: The answer is no. Calling static member functions is not an instance. But calling a virtual function requires a pointer to a virtual function table from an instance to get the address of the function, so calling a virtual function requires an instance. They contradict each other.


How to reference a global variable that has already been defined.

You can use the method of referencing a header file or the extern keyword.
With a reference header file, if you write the variable incorrectly, the error occurs during compilation.
In extern mode, if you write the variable name incorrectly, the error will not be made during compilation and the error will be made during the connection.


different points of database cold backup and hot backup and their advantages

A hot backup is a database that is in archive mode and is backed up while the database is still working. A cold backup is a database that is backed up after the database is closed and applies to all schemas. The advantage of hot backup is that when the backup is in place, the database can still be used and the database can be restored to any point in time. The advantage of a cold backup is that its backup and recovery operations are fairly simple, and because a cold backed up database can work in a non-archive mode, the database performance is slightly better than the archive mode. (Because the archive log will not be written to the hard drive)
the principle of Ajax, how to achieve refresh and its advantages

Ajax, "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), refers to a web development technology that creates interactive Web applications.

Web pages that use AJAX technology, use JavaScript and server communications, get data, and then refresh specific portions of the page by modifying some elements in the DOM of the Web page.

With Ajax technology, there is less data to interact with the server because you only need to update part of the page, not all of it. This lowers the load on the server and increases the response speed of the client. In addition, Ajax does not need to install plug-ins in the browser.

For more on Ajax content, refer to:
Http://baike.baidu.com/view/1641.htm


What is the difference between #include "filename.h" in C language and #include <filename.h>.

#include "filename.h" is first found in the directory that contains the original file of the program, and if it is not found, go to the system directory to find it.
#include <filename.h> go directly to the system directory to find.
C + +, a string class that has no copy constructor and overload = operator, what happens and how to resolve it.

If you do not define a copy constructor and an overload = operator, the system automatically generates a bitwise copy function.
When we initialize a string with string (for example, string a ("abc"); String b = A;), two objects will point to the same memory address. In the destructor of two objects, we will call the same memory block two times to delete, resulting in an indeterminate result.
When we assign a string to another string (for example, string a ("abc"); String B ("CDE"); b = A;) In addition to the multiple calls to destructors above, a memory leak can occur because the data that the original object B points to is not deleted correctly.

Solution:
1. Add these two functions.
2. Do not use these two functions.
-Do not initialize string with string: String A ("abc") can be used; String B (A.c_str ()); Replace.
-Do not assign a string to a string, including a string parameter that cannot be passed by a value method: Use pointers as much as possible.


N is an odd number, proving that N (n^2-1) can be divisible by 24.

Which is to prove that N (n^2-1) is divisible by 8 and 3.

Because n is odd, suppose n=2x+1, where x is an integer.
N (n^2-1)
= (2x+1) ((2x+1) ^2-1)
= (2x+1) (4x^2+4x+1-1)
= (2x+1) 4x (x+1)
Obviously X (x+1) can be divisible by 2, so (2x+1) 4x (x+1) can be divisible by 8.

The remainder of x divided by 3 may be 0,1,2, and the corresponding x,x+1,2x+1 can be divisible by 3. That is to say (2x+1) 4x (x+1) is divisible by 3.
So N (n^2-1) can be divisible by 24.


from the input URL to the display page, what happened in the background.

In simple terms, there are the following steps:
1. Find the IP address corresponding to the domain name. This step will look for browser caching, system caching, router caching, ISP DNS caching, and root domain server.
2. Send the request to the IP corresponding server.
3. The server responds to the request and sends back the content of the Web page.
4. Browser parsing Web page content.
Of course, since pages may be redirected, or embedded with images, AJAX, other subsites, and so on, these 4 steps may be repeated several times before the final page can be displayed to the user.

A more detailed explanation can refer to:
Http://www.cnblogs.com/wenanry/archive/2010/02/25/1673368.html
http://igoro.com/archive/what-really-happens-when-you-navigate-to-a-url/





*************************************************************************************************************** **************************************************************************

The above contents refer to the

He Haitao Blog

Http://hi.baidu.com/mianshiti/home

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.