为者常成,行者常至。

持续做一些细小而有用的事情。

C/C++基础知识总结

[006] HIWORD宏取高16位

[005] 使用strcmp需判断参数是否为NULL

[004] main函数的第三个参数envp

有的编译器支持三个参数的main函数,但不推荐这么写。


[003] 引用 reference

引用的本质是常量指针。 type * const p

引用的精髓在于传参。

函数有大型对象作参数时,使用引用参数可以提高传参效率。


[002] 函数的默认参数

默认的顺序从右到左,且不能跳跃。

默认参数在声明处。(给调用者看的

带默认参数的函数与重载函数易导致二义性。


[001] sizeof为求字节运算符,而不是一个函数。

The result of the sizeof operator is of type size_t, an integral type defined in the include file STDDEF.H.

This operator allows you to avoid specifying machine-dependent data sizes in your programs.

The sizeof operator never yields 0, even for an empty class.

When applied to a structure type or variable, sizeof returns the actual size, which may include padding bytes inserted for alignment.

 

posted on 2017-03-07 19:06  SoCode  阅读(161)  评论(0编辑  收藏  举报

导航