Some minor differences between c ++ and c ++ C ++ type checks are more rigorous in c language. When a character is passed in as a function parameter, it is used as an integer int, sizeof ('C') = sizeof (int); further, the c compiler treats character constants as Integer constants: putchar (10) is equivalent to putchar ('\ n. In C ++, sizeof ('C') = 1. For more information, sizeof (wchar_t) = 4. Therefore, it is easy to represent 65,536 different Unicode characters. In C ++, the difference function depends not only on its function name, but also on its parameters. Therefore, putchar (10) calls the putchar (int) version, and putchar ('\ n') calls the putchar (char) version. The prototype check of c ++ functions is stricter. For example, the function definition in c: void func (); indicates that the function func () exists and has no return value. This statement does not specify the number of formal parameters. But in C ++, it indicates that it cannot be passed in as a parameter!
In the main function C ++, the main function can be written in two ways: int main () and int main (int argc, char ** argv). The return type in the main function is int, it is not void. If no return statement is displayed, 0 is returned by default. If a return statement is written, it must keep up with an integer value, such as return 1; write only return; which is a serious error.
When calling the type check function, the prototype must be strictly matched ., However, C ++ does not include the cstdio header file by default. Some compilers in the C language are sponsoring stdio. h. Function-related function overloading C ++ supports function overloading. Function overload must meet. the function name is the same. B. the parameter table is different from the c. the attributes of the parameters are different, that is, whether the const is used for the overload function during compilation. Another name is used internally for expression. The terminology is "name mangling", such as void show (int) --> VshowI, void show (char *) --> VshowCP.
The default value of the parameter must appear in the function definition rather than in the function implementation. The code is more elegant. 0-pointers and nullptrC ++ all zero values are 0. in C, NULL indicates 0 in the pointer context. In C ++, NULL should be avoided, although its macro definition is 0.c++ 11, a New Keyword nullptr is introduced to indicate a zero-value pointer, it can only be assigned to functions in the C Runtime Library of the pointer type, however, the prefix of extern "C" must be added to C89. Local variables must be defined at the beginning of the function or statement block! Note that you are still using VC6.0. For your better code career, discard it. C99 supports local definition, which is a major improvement of C. C ++ can define local variables anywhere. In C ++, the struct can omit the struct keyword C ++ when defining variables. The struct can contain functions, that is, the default attribute is a public class.