摘要:【面试题2-10】static 有什么作用 (1)在函数体内,一个被声明为静态的变量在这一函数被调用的过程中维持其值不变 (2)在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所有函数访问,但不能被模块外其他函数访问 (3)在模块内,一个被声明为静态的函数只可被这一模块内的其他函数调用。
阅读全文
摘要:【题目4-5】编程实现 strcpy 函数 char* strcpy(char* strDest, const char* strSrc) 【题目4-6】编程实现 memcpy 函数 void* memcpy(void* memTo, const void* memFrom, size_t size
阅读全文
摘要:C++ adds a new compound type to the language - the reference variable. A reference is a name that acts as an alias, or an alternative name, for a prev
阅读全文
摘要:因为SP's jump, 函数调用要引入额外的时间开销。 C++针对此问题,引入 inline 函数避免此开销,提高程序运行效率。 Inline functions are a C++ enhancement designed to speed up programs.The primary dis
阅读全文
摘要:【题目2-2】用#define 实现宏求最大值和最小值 #define MAX(x,y) (((x)>(y))?(x):(y)) #define MIN(x,y) (((x)<(y))?(x):(y)) 在宏中需要把参数小心地用括号括起来,因为宏只是简单的文本替换,如果不注意,很容易引起歧义 【题目
阅读全文
摘要:【牛客题目1】在Visual C++ 和 Mingw64平台上,short a[100], sizeof(a) 返回什么? A. 2 B. 4 C. 100 D. 200 E. 400 答案:D Reference: https://www.nowcoder.com/test/question/do
阅读全文
摘要:const 变量一经赋值,不能修改 若在源代码中,const变量被修改,则编译器会报错 'l-value specifies const object' (一) 常量指针 vs 指针常量 【面试题2-7】 1 #include <stdio.h> 2 3 int main() 4 { 5 const
阅读全文