# The written questions of C + +

Source: Internet
Author: User
Tags file copy socket blocking

# The written questions of C + +

+ include<> and include "" Difference

+ sizeof operator and string length

>

char *p = "Hello World";

Char q[] = "Hello World";

sizeof (p), sizeof (q), strlen (p), strlen (q) values?

# # #结果

>

[Email protected]:~/train$./a.out

sizeof P:12

Strlen p:11

sizeof Q:4

Strlen q:11

+ The difference between the malloc function and the new operator

>

Malloc/free is a standard library function, and New/delete is a C + + operator

+ Initialize COMPUTE size return type Inner object class

+ New is malloc+ initialization

+ Destruction, automatic management of memory

+ Precautions

+ understanding of socket blocking, non-blocking, synchronous, asynchronous problems

>

The difference between blocking IO and non-blocking IO is that the application's call returns immediately!

+ Setup process pseudo-code for socket server

>

Server-side:

1. Create ServerSocket object, bind listening port

2. Listening for client requests via the Accept () method

3. After the connection is established, read the request information sent by the client via the output stream

4. Send response information via output flow to client

5. Close Related Resources

+ extern "C"

>

Note the use of the extern keyword, as opposed to static.

The main purpose of extern "C" is to be able to correctly implement C + + code calls to other C language code.

The addition of extern "C" instructs the compiler to compile this part of the code in C instead of C + +.

Because C + + supports function overloading, the function's parameter type is set during the compiler compiler function

Also added to the compiled code, not just the name of the function;

The C language does not support function overloading, so a function that compiles C code does not take on the argument type of the function.

The general includes the function name.

For example, you have developed a DLL library with C, in order to enable the C + + language to call your DLL output (export) function,

You need to use extern "C" to force the compiler not to modify your function name.

+ Write a cross-platform file copy function

>

Cross-platform can be implemented using the Fopen,fread,fwrite,fclose function in Class C libraries.

+ #ifdef, #define, #ifndef

>

Prevents duplicate inclusion and compilation of header files.

+ threads, process differences and connections

>

Process: Allocates the basic unit of the management resource, the size of the process space, and the five state transitions.

Threads: The basic unit of CPU scheduling.

Is there a separate space, and what does the independent space mean? Switching overhead

# The written questions of C + +

Related Article

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.