![](https://img-blog.csdnimg.cn/c889e7fa29de4afebd1aebf33898ac3d.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
C++
C++学习笔记
0-1背包
主要分享本人的C/C++、python、数据结构等学习笔记,希望跟大家一起学习,一起进步。在专栏中查看更加方便。
展开
-
list、简单的迭代器
头文件#pragma once#ifndef LIST_H#define LIST_H//防止头文件重复引入#include<initializer_list>namespace liujin{ template<class T> void Swap(T& x, T& y) { T tmp = x; x = y; y = tmp; } template<class _Ty> class list { private原创 2022-02-21 17:15:52 · 560 阅读 · 0 评论 -
5、用C++实现双链表
头文件#include<iostream>using namespace std;class Node{private: int _val; Node* _next; Node* _pre;public: Node(int val = int()) :_val(val),_next(nullptr),_pre(nullptr)//初始化列表 { } Node(const Node& src)//拷贝构造 :_val(src._val),_next(nul原创 2021-12-12 11:57:31 · 708 阅读 · 0 评论 -
多线程单例模式
ex:设计一个类:1、只能产生一个对象2、在任何地方都能使用到这个对象#include<mutex>#include<iostream>using namespace std;class Sun{public : static Sun* get_sun() { if (nullptr == _only_sun)//双重判断,因为加锁代价有点大 { _lock->lock();//加锁 if (nullptr == _only_sun)原创 2021-12-11 22:04:19 · 604 阅读 · 0 评论 -
3、关键字、标识符命名规则
C++关键字:原创 2021-09-27 20:37:48 · 70 阅读 · 0 评论 -
2、变量、常量、define、const
1、变量变量定义的语法:变量的类型 +标识符(变量名)=初始值变量存在的意义就是为了更好的管理内存。#include<iostream>using namespace std;int main(){ int a = 10; cout << "a=%d" << a << endl;//将a在屏幕上输出,这里不用%d cout << "a=" <<a + 10;//endl就是换行 cout << "a="原创 2021-09-24 17:35:35 · 73 阅读 · 0 评论 -
1、C++第一个程序
1、第一个C++程序#include<iostream>using namespace std;int main(){ cout << "hello C++"<<endl; system("pause"); return 0;}原创 2021-09-23 10:57:34 · 40 阅读 · 0 评论