private variable of the parent class? (Huawei written questions)Answer: As long as the base class has declared the Virtue keyword when defining a member function, when overridden by a derived class, the Virtue keyword can be added without affecting the implementation of the polymorphic. The subclass has all the variables of the parent class (except static) in the space.49. Complete string copy can use sprintf, strcpy and memcpy functions, what is the
As we all know, network TCP and stream socket cannot guarantee that the received packets are logically complete. Maybe a logically complete packet is sent in two segments, therefore, we need to organize the received packets (physical packets) into logical packets when using the stream socket. And then process it. The sorting Package function is called the packaging function. The following code uses the ring buffer to implement a package function. Ring buffering can reduce unnecessary
power of 2. The implementation is as follows:static inline uint32_t roundup_power_of_2(uint32_t a){if (a == 0) return 0;uint32_t position = 0;for (int i = a; i != 0; i >>= 1) position++;return static_castuint32_t>(1
2. Linux implementation Kfifo and analysisThe implementation techniques in the Linux kernel are kfifo mainly focused on the method of putting the data put and the method of fetching the data get . The code is as follows:Unsignedint __kfifo_put (struct Kfifo *fifo,UnsignedChar *buf
is no null character copy at this time. The difference between strcpy,strncpy and memcpy and how to use itstrcpy , strncpy, memcpy these three C language functions we in the host code writing will be very frequent use, but three functions of the difference, the use of the attention of what is necessary to say.This article is written in reference to the C standard library.First, function description1 ,
address directly.
2. Variables modified in the Interrupt service program for testing by other programs require additional volatile.
3. The signs shared between tasks in a multitasking environment should be added volatile.
4. Memory-mapped hardware registers are usually also voliate, because each read and write to it may have different meanings.
5. Frequent use of volatile is likely to increase code size and reduce performance.
8, bidirectional linked list operation question:
/* Node Definition
statements are correct in the GNU Compiler:Pvoid ++; // GNU: CorrectPvoid + = 1; // GNU: Correct
The execution result of pvoid ++ is increased by 1.
In actual programming, to cater to ANSI standards and improve program portability, we can write code that implements the same function as below:Void * pvoid;(Char *) pvoid ++; // ANSI: Correct; GNU: Correct(Char *) pvoid + = 1; // ANSI: error; GNU: Correct
There are some differences between GNU and ANSI. In general, GNU is more open than ANSI and p
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.