会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
首页
新随笔
管理
订阅
随笔- 28 文章- 0 评论- 0 阅读-
12485
随笔分类 -
cpp
c++
c++文件读写
摘要:三个类: ofstream: 写文件流 ifstream: 读文件流 fstream: 读写文件流 基本使用 // basic file operations #include <iostream> #include <fstream> using namespace std; int main (
阅读全文
posted @
2022-05-25 23:05
suntus
阅读(104)
评论(0)
推荐(0)
编辑
delete this
摘要:一般不要用,用了就要注意一下几点 1. 只能用于 new 申请的对象,不能用于栈上对象 #include <iostream> class A { public: void func() { delete this; } }; int main(int argc, char const *argv[
阅读全文
posted @
2022-05-25 23:01
suntus
阅读(83)
评论(0)
推荐(0)
编辑
c++字符串操作
摘要:1. string转map 主要用到 std::getline() 和 std::ws #include <map> #include <string> #include <sstream> #include <iostream> std::map<std::string, std::string>
阅读全文
posted @
2021-08-28 22:20
suntus
阅读(99)
评论(0)
推荐(0)
编辑
用到的cmake
摘要:1. CheckCxxCompilerFlag 模块 检查cxx编译器是否支持某个flag include(CheckCxxCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++1" COMPILER_SUPPORTS_CXX11) if (COMPILER_
阅读全文
posted @
2021-08-16 11:19
suntus
阅读(43)
评论(0)
推荐(0)
编辑
vector相关
摘要:1. 构造 空vector: vector(): 空vector n个元素: vector(int size): n个元素位置 vector(int size, const T &t): n个元素,均初始化为t 复制构造: vector(const vector &): 复制构造 vector(be
阅读全文
posted @
2021-08-01 17:13
suntus
阅读(41)
评论(0)
推荐(0)
编辑
set相关
摘要:1. 定义 #include <set> template< class Key, class Compare = std::less<Key>, class Allocator = std::allocator<Key> > class set; 2. 初始化 默认构造,空set 范围构造,使用另
阅读全文
posted @
2021-07-26 23:11
suntus
阅读(36)
评论(0)
推荐(0)
编辑
shared_from_this
摘要:1. 介绍 关于智能指针 shared_ptr 很有意思的一个问题。 可以用 std::shared_ptr 将裸指针封装起来,变成带引用计数的智能指针,当引用计数为0,C++会自动把裸指针指向的内存回收。 先定义一个类 class A { public: A(); private: int a_;
阅读全文
posted @
2021-06-26 23:39
suntus
阅读(562)
评论(0)
推荐(0)
编辑
用到的cpp-持续更新
摘要:C++标准保证把 std::vector 的元素排列跟数组一样,因此可以这样用: &*my_array.begin() 取到相应的数组. auto it = std::max_element(v.begin(), v.end()) 取到最大元素的iterator std::move() 将变量变为右
阅读全文
posted @
2021-06-20 23:17
suntus
阅读(40)
评论(0)
推荐(0)
编辑
公告
昵称:
suntus
园龄:
12年5个月
粉丝:
0
关注:
3
+加关注
<
2025年3月
>
日
一
二
三
四
五
六
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
我的标签
linux
(15)
cpp
(11)
media
(3)
tools
(2)
ros
(2)
net
(2)
libhv
(2)
log
(1)
随笔分类
(26)
cpp(8)
linux开发(14)
media(1)
夜深人静看代码(3)
随笔档案
(28)
2022年6月(1)
2022年5月(3)
2021年12月(2)
2021年10月(1)
2021年9月(6)
2021年8月(5)
2021年7月(2)
2021年6月(8)
阅读排行榜
1. GB28181实现对比(3056)
2. 在centos上切换不同版本的gcc(2333)
3. ros图像处理相关(1961)
4. linux标准输入输出(1037)
5. log4z(866)
点击右上角即可分享