OUC_LiuX's Blog

为天地立心,为生民立命。
为往圣继绝学,为万世开太平。
虽未能至,心向往之。

Series Article of cpp -- 21

引用,指针,智能指针

引用和指针 区别 指针 存放的是地址,指针可以被重新赋值,可以在初始化时指向一个对象,也可以不赋值即 pointer = nullptr;在其它时刻也可以指向另一个对象。指针在生命周期内随时都可能是空指针,所以在每次使用时都要做检查,防止出现空指针异常问题。 引用 作为变量别名而存在,总是指向它最初代表的那个对象。引用恒不需要检查是否为空,因为引用永远都不会为空,它一定有本体,一定得代...

Series Article of cpp -- 20

unordered 无序容器和常规容器的区别

以 set 为例说明 unordered 无序容器和常规容器的区别,map 也是一样的。 底层数据结构 set基于红黑树实现,红黑树具有自动排序的功能,因此map内部所有的数据,在任何时候,都是有序的。 unordered_set基于哈希表,数据插入和查找的时间复杂度很低,几乎是常数时间,而代价是消耗比较多的内存,无自动排序功能。底层实现上,使用一个下标范围比较大的数组来...

Series Article of Python Using -- 08

Python实录08 -- 'str' object does not support item assignment

s1 = "Hello World" s2 = "" j = 0 for i in range(len(s1)): s2[j] = s1[i] j = j + 1 报错: TypeError: ‘str’ object does not support item assignment 曲线救国方案: >>> str1 = "myst...

Series Article of Python Using -- 07

Python实录07 -- 在 python2 中使用 python3 语法

from __future__ import division, absolute_import, print_function

Series Article of UbuntuOS -- 26

Ubuntu apt 下载报错先尝试换源更新

备份原有源。 sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup 换清华或阿里源(镜像) 编辑 /etc/apt/sources.list,替换原有内容为以下: // Ali: deb http://mirrors.aliyun.com/ubu...

Series Article of UbuntuOS -- 25

Ubuntu 挂载外部存储设备相关问题

无法挂在外部存储设备,提示 mount: wrong fs type, bad option, bad superblock on /dev/xxx, missing codepage or helper program, or other error: 原因:存储设备没有格式化或文件系统格式错误。通常 Ubuntu 系统可接受的文件格式为 ntfs 和 ext4。可以通过 l...

Series Article of UbuntuOS -- 24

Ubuntu 网络问题万金油

记录一些连接有线以太网的服务器端遇到的网络问题及万金油解决方案。 1. ifconfig 找不到有线网卡 这种情况下 ifconfig 命令的返回信息只有一个 lo 本地回环信息,说明有线网卡被关掉了。使用 ip addr 命令查找本机网卡信息,加入找到的网卡是 etn1 ,将之挂载: sudo ifconfig etn1 up // 或者 sudo ifup etn...

Series Article of Jetson -- 01

Jetson Nano 使用实录01 -- Linux 编译 protobuf

安装依赖 sudo apt-get install autoconf automake libtool curl make g++ unzip 下载源码 项目requirements.txt指定了版本号为 3.11.4,在 https://github.com/protocolbuffers/protobuf/tags 通过 tag 寻找。使用 wget 或...

Series Article of cpp -- 19

memset只能赋值为0或-1

当我们运行下面的一段代码试图将数组中的数字全置为 1: #include<bits/stdc++.h> using namespace std; int main() { int arr[5],b; memset(arr,1,sizeof(arr)); for(auto i:arr) cout<<i<<" "; } 会发现结果为:16843...

Series Article of cpp -- 18

C++参数传递,数组引用传递,保护数组退化为指针

在进行参数的传递时,数组引用可以帮助我们防止数组退化为指针,而这是我们在编程中很难注意到的问题。 下面来看一个实例: #include <iostream> void each(int int_ref[10]) { std::cout << sizeof(int_ref)<<std::endl; for(int...