avatar
文章
30
标签
0
分类
4
首页
归档
标签
分类
链接
关于
ZuowangDev's Blog
首页
归档
标签
分类
链接
关于

ZuowangDev's Blog

Hello World
发表于2025-12-22
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. Quick StartCreate a new post1$ hexo new "My New Post" More info: Writing Run server1$ hexo server More info: Server Generate static files1$ hexo generate More info: Generating Deploy to remote sites1$ hexo deploy More info: Deployment
Data Structures
发表于2025-12-22|The Algorithms C++
linked_list.cpp The linked list is a data structure used for holding a sequence of values, which can be added, removed and displayed. namespace: 定义命名空间,防止变量混淆。 std::shared_ptr name; shared_ptr: 共享指针,支持多个指针指向同一个元素,当元素没有指针指向,则自动释放内存,核心是指针计数器。 explicit: 修饰单参数构造函数,防止隐式类型转换,不能使用”=”进行构造。 std::make_shared(); make_shared: 性能更佳的返回shared_ptr。无法使用私有的构造函数,如果是私有的,必须手动使用new;不支持自定义删除器。 shared_ptr.reset(): 将指针重置为空状态,减小该指针所管理对象的引用计数,当引用计数变为0,释放所管理的内存对象。 node.hpp
Chapter 2: Variables and Basics Types
发表于2025-12-22|C++ Primer
Extend the language by defining their own types Provide library routines that define useful functions and types not otherwise built into the language Chapter 2: built-in types.Chapter 3: string and vector.Chapter 4 - 6: expressions, statements, and functions.Chapter 7: class Variables and Basic Types Type Meaning Min Size bool boolean NA char character 8 bits wchar_t wide character 16 bits char16_t Unicode character 16 bits char32_t Unicode character 32 bits short short int...
Chapter 8: The IO Library
发表于2025-12-22|C++ Primer
The IO Library 从流中读取和写入的IO操作 IO类 iostream: 读写流的基本操作的头文件 isteam, wistream: 从流中读取 ostream, wostream: 向流中写入 iostream, wiostream: 读写流 fstream: 读写命名文件的类型的头文件 ifstream, wifstream: 从文件中读取数据 ofstream, wofstream: 向文件中写入数据 fstream, wfstream: 读写文件 sstream: 读写内存string对象的类型头文件 istringstream, wistringstream: 从string读取数据 ostringstream, wostringstream: 向string写入数据 stringstream, wstringstream: 读写string 不能拷贝或者对IO对象赋值,IO操作的函数通常以引用的方式传递和返回流。读写IO对象会改变其状态,因此引用不能是const的 strm::iostate: 表达条件状态的完整功能 strm::bad...
Chapter 3: Strings, Vectors, and Arrays
发表于2025-12-22|C++ Primer
Strings, Vectors, and Arrays string: A variable-length sequence of characters. vector: A variable-length sequence of objects of a given type. Namespace using Declarationsusing namespace 123456789101112#include <iostream>using std::cin;using std::cout;int main(){ int i; cin >> i; cout << i; return 0;} ** Headers Should Not Include using Declarations ** : To avoid the namespace is used every program that includes that header files. Library string Type s...
Chapter 5: Statements
发表于2025-12-22|C++ Primer
StatementsSimple StatementsStatement ScopeConditional StatementsIterative StatementsJump Statementstry Block and Exception Handling
Chapter 9: Sequential Containers
发表于2025-12-22|C++ Primer
Sequential Containers 提供控制元素存储和访问顺序的能力。 顺序容器概述不同容器在以下方面都有不同的性能折中: 向容器中添加或从中删除元素的cost; 非顺序访问容器中元素的代价 vector: 可变大小数组。支持快速随机访问(快速搜索)。除了push_back之外,其他位置插入和删除元素可能很慢。 deque: 双端队列。支持快速随机访问。在头尾插入/删除很快。 list: 双向链表。只支持双向顺序访问。插入/删除元素很快。 forward_list: 单向链表。只支持单向访问。插入/删除元素很快。 array: 固定大小数组。支持快速随机访问。不能添加和删除元素。 string: 与vector类似,专门用来保存字符。随机访问快,在尾部插入删除块。 确定使用哪个容器的规则:主要考虑的两点:是否需要在中间插入或删除元素;是否需要随机访问。 除非有理由选择其他容器,优先使用vector 如果程序有很多很小的元素,且空间的额外开销很重要,则不要使用list或forward_lsit 如果程序需要在头尾插入或删除元素,但不...
Chapter 1: Getting Started
发表于2025-12-22|C++ Primer
Getting Started types, variables, expressions, statements, and functions. compile and execute. The way to learn a new programming language is to write programs. Define variables Do input and output Use a data structure to hold the data Test whether two records have the same ISBN Contain a loop that will process every record in the transaction file C++ Program return type function name parameter list function body Compiling and Executing 1234# GNUg++ -o prog1 prog1.cc# Windowscl /EHsc prog...
Chapter 10: Generic Algorithm
发表于2025-12-22|C++ Primer
Generic Algorithm 不针对具体容器,在迭代器层次进行操作 Start 头文件algorithm, numeric 只读算法 find, accumulate, equal find: 容器中查找元素; accumulate: 指定容器范围,给定初值(第三个参数, 确定使用哪个加法运算和返回值类型); equal: 确定两个序列是否保存相同的值,传入第一个序列的首尾,和第二个序列的首,第二个序列的元素数目不小于第一个序列。 写容器元素算法 必须保证序列原大小至少不小于要求算法写入的元素数目。向目的位置迭代器写入数据的算法假定目的位置足够大,能容纳要写入的元素。 back_inserter: 插入迭代器。接受一个容器的引用,返回一个与该容器绑定的插入迭代器。使用此迭代器赋值时候,会调用push_back将元素添加到容器。 重排容器元素的算法 sort: 通过<实现排序; unique: 将序列重排,将相邻的重复项消除; erase: 删除两个迭代器之间的元素 定制操作 希望按照自己的想法完成操作,如,重载的sort函数接受第三个参数,谓词。 谓词: ...
Chapter 6: Functions
发表于2025-12-22|C++ Primer
123
avatar
ZuowangDev
文章
30
标签
0
分类
4
Follow Me
公告
This is my Blog
最新文章
Hello World2025-12-22
Data Structures2025-12-22
Chapter 2: Variables and Basics Types2025-12-22
Chapter 8: The IO Library2025-12-22
Chapter 3: Strings, Vectors, and Arrays2025-12-22
分类
  • 6.058
  • C++ Primer13
  • EasyScheme7
  • The Algorithms C++1
归档
  • 十二月 2025 15
  • 十一月 2024 7
  • 八月 2024 8
网站信息
文章数目 :
30
最后更新时间 :
© 2025 By ZuowangDev
Stay hungry & Stay foolish