随笔分类 -  C++

博客内容出自于 [1] C和C++程序员面试密集-精选最常见的C/C++面试真题 [2] 牛客网 [3] C++ prime
C++ static
摘要:【面试题2-10】static 有什么作用 (1)在函数体内,一个被声明为静态的变量在这一函数被调用的过程中维持其值不变 (2)在模块内(但在函数体外),一个被声明为静态的变量可以被模块内所有函数访问,但不能被模块外其他函数访问 (3)在模块内,一个被声明为静态的函数只可被这一模块内的其他函数调用。 阅读全文

posted @ 2020-03-12 13:03 猪伯 阅读(255) 评论(0) 推荐(0)

C++ strcpy, memcpy,strlen 实现
摘要:【题目4-5】编程实现 strcpy 函数 char* strcpy(char* strDest, const char* strSrc) 【题目4-6】编程实现 memcpy 函数 void* memcpy(void* memTo, const void* memFrom, size_t size 阅读全文

posted @ 2020-03-12 12:58 猪伯 阅读(338) 评论(0) 推荐(0)

C++ 引用变量(Reference variable)
摘要: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 阅读全文

posted @ 2020-03-11 21:17 猪伯 阅读(1721) 评论(0) 推荐(0)

C++ inline 内联函数
摘要:因为SP's jump, 函数调用要引入额外的时间开销。 C++针对此问题,引入 inline 函数避免此开销,提高程序运行效率。 Inline functions are a C++ enhancement designed to speed up programs.The primary dis 阅读全文

posted @ 2020-03-11 19:18 猪伯 阅读(317) 评论(0) 推荐(0)

C++ define 的用法
摘要:【题目2-2】用#define 实现宏求最大值和最小值 #define MAX(x,y) (((x)>(y))?(x):(y)) #define MIN(x,y) (((x)<(y))?(x):(y)) 在宏中需要把参数小心地用括号括起来,因为宏只是简单的文本替换,如果不注意,很容易引起歧义 【题目 阅读全文

posted @ 2020-03-10 17:39 猪伯 阅读(870) 评论(0) 推荐(0)

C++ 中的 sizeof()
摘要:【牛客题目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 阅读全文

posted @ 2020-03-07 02:54 猪伯 阅读(852) 评论(0) 推荐(0)

C++ - const 关键字
摘要:const 变量一经赋值,不能修改 若在源代码中,const变量被修改,则编译器会报错 'l-value specifies const object' (一) 常量指针 vs 指针常量 【面试题2-7】 1 #include <stdio.h> 2 3 int main() 4 { 5 const 阅读全文

posted @ 2020-03-03 06:46 猪伯 阅读(175) 评论(0) 推荐(0)

导航