Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merged a no of changes from different forks #2

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ef356c3
add
SherryCoder Sep 8, 2018
9b5b852
Update C++对象模型.md
lys19xx Nov 19, 2018
ec6983d
Update C++对象模型.md
lys19xx Nov 19, 2018
e31a29d
Update C++对象模型.md
lys19xx Nov 19, 2018
8dac822
Update C++对象模型.md
lys19xx Nov 19, 2018
f09f2b8
Merge pull request #1 from SherryCoder/master
Rajpratik71 Nov 28, 2018
5911db6
Merge pull request #2 from lys19xx/master
Rajpratik71 Nov 28, 2018
38b939d
添加 《深入理解Linux内核》
arkingc Jan 15, 2019
4d7a1db
修改 README.md
arkingc Jan 15, 2019
36ca703
修改 《深入理解Linux内核》
arkingc Jan 15, 2019
89c0b81
修改 README.md
arkingc Jan 15, 2019
972975a
修改 《深入理解Linux内核》
arkingc Jan 15, 2019
63117e4
修改 《深入理解Linux内核》
arkingc Jan 15, 2019
9a3271b
修改 《深入理解Linux内核》
arkingc Jan 15, 2019
dc91a1b
修改 《深入理解Linux内核》
arkingc Jan 16, 2019
93da832
修改 《深入理解Linux内核》
arkingc Jan 16, 2019
b6c1cdd
修改 《深入理解Linux内核》
arkingc Jan 16, 2019
7ff5efe
修改 《深入理解Linux内核》
arkingc Jan 17, 2019
f128e03
修改 《深入理解Linux内核》
arkingc Jan 17, 2019
1acfaa5
Update C++.md
jz0224 Jan 31, 2019
0e037ad
Update C++.md
jz0224 Jan 31, 2019
ee79362
Update C++.md
jz0224 Feb 1, 2019
e19b942
Update C++.md
jz0224 Feb 1, 2019
59ced32
Initial WhiteSource configuration file
Feb 4, 2019
c69289c
Merge pull request #3 from arkingc/dev
Rajpratik71 Feb 5, 2019
76e2713
Merge pull request #4 from arkingc/master
Rajpratik71 Feb 5, 2019
4d0208b
Merge pull request #5 from jz0224/master
Rajpratik71 Feb 5, 2019
29c7c9b
Update C++.md
jz0224 Feb 15, 2019
3abe267
Update C++.md
jz0224 Feb 15, 2019
6218f4a
Update C++.md
jz0224 Feb 16, 2019
c3e57a8
Update 计算机网络.md
raygatsby Feb 17, 2019
3eb6db2
Create C++基础.md
FlyawayfromCN Feb 21, 2019
2fd46fe
Update C++基础.md
FlyawayfromCN Feb 21, 2019
5f0d820
Update 操作系统.md
jz0224 Mar 9, 2019
941d175
Update 操作系统.md
jz0224 Mar 13, 2019
c1496e0
Update 操作系统.md
jz0224 Mar 14, 2019
6efc9b1
Merge pull request #6 from LittleTree1993/patch-1
Rajpratik71 Apr 11, 2019
017fb42
Merge pull request #7 from jz0224/master
Rajpratik71 Apr 11, 2019
bc90f7d
Merge pull request #8 from XXieJY/master
Rajpratik71 Apr 11, 2019
508c2cf
Merge pull request #9 from xlisp/master
Rajpratik71 Apr 11, 2019
75f964f
[ImgBot] Optimize images
ImgBotApp Jun 19, 2019
7241cd0
Delete .whitesource
Rajpratik71 Jun 19, 2019
f315480
Merge pull request #12 from Rajpratik71/imgbot
Rajpratik71 Jun 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions C++/C++基础.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
1. 变量声明和变量定义的区别
* 声明不分配地址和存储空间,定义分配。
* 同一个变量可以声明多次,只能定义一次。
2. typedef和define的区别
* type定义数据类型的别名增加可读性,define定义常亮和宏
* typedef在编译时期进行有类型检查,define在预编译时期进行只是简单字符串替换没有类型检查。
3. 重写和重载的区别
* 重写的函数名参数返回值完全相同,重写用于子类定义父类虚函数。
* 重载只有函数名相同,但是参数必须不同。
4. static
* static全局变量和static全局函数只能在当前模块内被访问。
* 函数内static变量只被分配一次,且函数退出后也不会被销毁。
* 类内static成员变量只被创建一次,所有实例化对象共用同一份static成员变量。
* 类内static成员函数同样被所有实例化对象共用,不接受this指针,只能访问类的static成员变量。

5. 深拷贝和浅拷贝
* 类中未定义拷贝构造函数时,系统调用默认拷贝构造函数即浅拷贝。当数据成员中有指针时,如果采用简单的浅拷贝,则两类中的两个指针将指向同一个地址,当对象快结束时,会调用两次析构函数,而导致指针悬挂现象,所以,此时,必须采用深拷贝。
* 深拷贝与浅拷贝的区别在于深拷贝会申请堆内存空间。

6. 引用和指针的区别
* 引用初始化后不能被改变引用对象,指针可以随时改变指向对象。
* 引用不可以为空,指针可以为空。

7. sizeof和strlen的区别
* sizeof是运算符,strlen是函数。sizeof在编译时计算,strlen在运行到它时进行计算。

8. 内存模型
* 内存分成5个区,他们分别是堆、栈、自由存储区、全局/静态存储区和常量存储区。
* 栈(由高向低):函数内局部变量在栈上创建,函数执行结束自动释放。容量有限。
* 堆(由低向高):就是那些由new分配的内存块一般一个new就要对应一个 delete。,需要手动管理。
* 自由存储区:由malloc等分配的内存块,它是用free来结束自己的生命的。
* 全局静态存储区:分配全局变量和静态变量。
* 常亮存储区:存放常量。

9. 内存分配:
* 常亮静态存储区在编译时分配。
* 函数执行时在栈区分配。
* new/malloc delete/free在堆区分配。

10. new/delete组合和malloc/free组合的区别:
* malloc/free是标准库函数,new/delete是关键字&运算符。new操作符从自由存储区(free store)上为对象动态分配内存空间,而malloc函数从堆上动态分配内存。
* new和delete会分别调用:构造函数和析构函数。
* new自动计算需要分配的空间,而malloc需要手工计算字节数
* new是类型安全的,而malloc不是。

11. 智能指针
* 智能指针使用引用计数器机制实现。建立一个引用计数器类对象,它内容应该包括指向类A对象的指针,以及引用计数器。在以后要使用对象A时,就直接使用该引用计数器类对象。
* 智能指针种类:shared_ptr, unique_ptr, weak_ptr。shared_ptr使用引用计数,每一个shared_ptr的拷贝都指向相同的内存。每使用他一次,内部的引用计数加1,每析构一次,内部的引用计数减1,减为0时,自动删除所指向的堆内存。shared_ptr内部的引用计数是线程安全的,但是对象的读取需要加锁。
4 changes: 2 additions & 2 deletions C++/C++对象模型.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* [附:使用gdb分析对象模型](#附使用gdb分析对象模型)
<!-- GFM-TOC -->

<br>
<br>
<br>
<br>
<br>
Expand Down Expand Up @@ -1872,4 +1872,4 @@ int main()

画图表示如下(typeinfo在虚函数表上方):

<div align="center"> <img src="../pic/cppmode-f-5.png"/> </div>
<div align="center"> <img src="../pic/cppmode-f-5.png"/> </div>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

* [《操作系统——精髓与设计原理》](操作系统/操作系统.md)
* [《UNIX环境高级编程》](操作系统/UNIX环境高级编程.md)
* [《深入理解Linux内核》](操作系统/深入理解Linux内核/book.md)

## 计算机网络

* [《计算机网络——自顶向下方法》](计算机网络/计算机网络.md)
* [《UNIX网络编程:卷1》](计算机网络/UNIX网络编程卷1.md)

## 数据结构与算法

* [1.排序](数据结构与算法/排序.md)
* [2.二叉树](数据结构与算法/二叉树.md)
* [3.堆](数据结构与算法/堆.md)
Expand Down
94 changes: 74 additions & 20 deletions interview/C++.md

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion interview/temp/C++.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,10 @@ public:
## 4.static函数与普通函数的区别

* static函数与普通函数作用域不同,仅在本文件。只在当前源文件中使用的函数应该说明为内部函数(static修饰的函数),内部函数应该在当前源文件中说明和定义。对于可在当前源文件以外使用的函数,应该在一个头文件中说明,要使用这些函数的源文件要包含这个头文件
* static函数在内存中只有一份,普通函数在每个被调用中维持一份拷贝(这里暂时不理解)
* static函数在内存中只有一份,普通函数在每个被调用中维持一份拷贝(这里暂时不理解)

## 5.extern关键字详解

作用:
* 与“C”一起用的时候,extern "C" void fun(int a, int b);则告诉编译器在编译fun这个函数名时按着C的规则去翻译相应的函数名而不是C++的。
* 当extern不与"C"在一起修饰变量或函数时,如在头文件中: extern int g_Int; 它的作用就是声明函数或全局变量的作用范围的关键字,其声明的函数和变量可以在本模块或其他模块中使用,记住它是一个声明不是定义!也就是说B模块(编译单元)要是引用模块(编译单元)A中定义的全局变量或函数时,它只要包含A模块的头文件即可,在编译阶段,模块B虽然找不到该函数或变量,但它不会报错,它会在连接时从模块A生成的目标代码中找到此函数。
Binary file modified interview/temp/pic/10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/8-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified interview/temp/pic/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading