1. What is the difference between _ tmain () and main?
People who have used C know that every cProgramThere will be a main (), but sometimes it is found that the main function is not int main (), but int _ tmain (), and the header file is not <iostream. h> but <stdafx. h> Are you confused? Let's take a look at their relationship. First of all, this _ tmain () is used to support the main alias used by Unicode. Since it is an alias, there should be a macro definition, where is it defined? Just in the one that puzzles you <stdafx. h>, there are two rows # include <stdio. h> # include <tchar. h> in the header file <tchar. h> Find the macro definition of _ tmain.
# DEFINE _ tmain main. Therefore, after pre-compilation, _ tmain becomes main. Now I understand it.
2. What is the difference between "\ n" and Endl in C ++?
"\ N" indicates a carriage return character string. STD: Endl is a stream operator. The output function is similar to the output "\ n", but it may be slightly different. STD: Endl outputs a line break and refreshes the buffer immediately. For example, STD: cout <STD: Endl; is equivalent to STD: cout <'\ n' <STD: flush;, or STD :: cout <'\ n'; STD: fflush (stdout );. Due to the overload of stream Operator <, for '\ n' and "\ n", the output effect is the same. For a stream with an output buffer (such as cout and clog), if you do not manually refresh the buffer, the output is automatically refreshed when the buffer is full. But for cout (compared with the file output stream, etc.), the buffer is generally not obvious. However, it is a good habit to use Endl instead of '\ n' if necessary. Refresh is unnecessary for unbuffered streams (such as standard error output stream cerr). You can directly use '\ n '. ---- Because direct input/output is related to the operating system, it may take some time to switch the kernel/user State. Frequent operations will greatly reduce the input/output efficiency, therefore, the input/output operations of the standard library are buffered. Specifically, a relatively fixed area (buffer zone) is saved in the memory to store temporary input or output. When necessary, the buffer zone is copied to the system device and the buffer zone is cleared. This process is called refresh.
The content of this article comes from: Baidu knows, which collects the content only for future convenience.
3. When "<" is used for STD: cout <"helo c ++";, it indicates the insertion operator, and sometimes it can also be used as a displacement operator, different meanings are called Operator overloading.
4. store the information in the computer. The storage location of the information and the memory space required must be specified. For example, int m; indicates that the memory size is determined by m for the memory location corresponding to int.
5. Classes define data formats and usage, while objects are entities created according to data format specifications.