随笔分类 -  C/C++

摘要: 阅读全文
posted @ 2023-11-22 11:51 蘑菇王国大聪明 阅读(50) 评论(0) 推荐(0) 编辑
摘要:什么是线程 注意: ps -Lf (进程名字)可以查看进程的线程 Linux内核实现线程的原理 首先先介绍一下三级页表: 线程创建 注意编译和链接的使用使用 -pthread表示引入线程库 /****************************************************** 阅读全文
posted @ 2022-03-02 19:57 蘑菇王国大聪明 阅读(35) 评论(0) 推荐(0) 编辑
摘要:n&((~n)+1) 阅读全文
posted @ 2021-09-21 17:42 蘑菇王国大聪明 阅读(96) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; template<class T> class SmartPtr{ public: explicit SmartPtr():ptr(nullptr), count(new int(0)){} explicit Smar 阅读全文
posted @ 2021-09-01 09:51 蘑菇王国大聪明 阅读(26) 评论(0) 推荐(0) 编辑
摘要:多线程的栈 #include <iostream> #include <vector> #include <mutex> #include <thread> #include <stack> #include <exception> using namespace std; template<cla 阅读全文
posted @ 2021-09-01 09:04 蘑菇王国大聪明 阅读(68) 评论(0) 推荐(0) 编辑
摘要:LRU缓存 struct Node{ int key; int value; Node* next; Node* pre; Node(): key(-1), value(-1), next(nullptr), pre(nullptr){} explicit Node(int key_, int va 阅读全文
posted @ 2021-09-01 08:45 蘑菇王国大聪明 阅读(21) 评论(0) 推荐(0) 编辑
摘要:#include <sstream> int main(){ vector<string> arr; string s; getline(cin, s); stringstream ss(s); while(getline(ss, s, ' ')){ arr.push_back(s); } for( 阅读全文
posted @ 2021-08-29 11:02 蘑菇王国大聪明 阅读(26) 评论(0) 推荐(0) 编辑
摘要:struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nullptr) {} explicit ListNode(int x) : val(x), next(nullptr) {} ListNode(int x, L 阅读全文
posted @ 2021-08-26 17:09 蘑菇王国大聪明 阅读(71) 评论(0) 推荐(0) 编辑
摘要:#include <iostream> using namespace std; #include <set> class Person{ public: Person(string name,int age): name(name),age(age) {} void printInformatio 阅读全文
posted @ 2021-07-17 15:41 蘑菇王国大聪明 阅读(90) 评论(0) 推荐(0) 编辑
摘要:1.创建一个Person类 // // Created by Administrator on 2021/7/16. // #ifndef C__TEST01_PERSON_HPP #define C__TEST01_PERSON_HPP template<class T1, class T2> c 阅读全文
posted @ 2021-07-16 19:21 蘑菇王国大聪明 阅读(78) 评论(0) 推荐(0) 编辑
摘要:1.继承的构造和析构的顺序 子类继承父类: (1)父类构造函数 (2)子类构造函数 (3)子类析构函数 (4)父类析构函数 不管怎么调用子类结果都是一样的: //通过父类创建子类 Animal *cat = new Cat(); delete cat; cat = NULL; cout<<endl; 阅读全文
posted @ 2021-07-16 09:52 蘑菇王国大聪明 阅读(59) 评论(0) 推荐(0) 编辑
摘要:友元函数中成员函数使用 #include <iostream> using namespace std; class BedRoom; //声明一个类 class GoodGay { public: GoodGay(); ~GoodGay(); void visit(); private: BedR 阅读全文
posted @ 2021-07-16 08:48 蘑菇王国大聪明 阅读(73) 评论(0) 推荐(0) 编辑
摘要:Father.hpp 1 // 2 // Created by Administrator on 2021/7/15. 3 // 4 5 #ifndef C__TEST01_FATHER_HPP 6 #define C__TEST01_FATHER_HPP 7 8 9 class Father { 阅读全文
posted @ 2021-07-15 19:58 蘑菇王国大聪明 阅读(103) 评论(0) 推荐(0) 编辑
摘要:1 // 2 // Created by Administrator on 2021/7/15. 3 // 4 5 #ifndef C__TEST01_PERSON_H 6 #define C__TEST01_PERSON_H 7 8 //类模板 9 template<class T1, class 阅读全文
posted @ 2021-07-15 19:56 蘑菇王国大聪明 阅读(29) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 //常量指针 5 void test01(){ 6 int a = 4; 7 int b = 2; 8 int *const p = &a; 9 cout<<"*p = "<<*p<<endl; 10 阅读全文
posted @ 2021-07-15 19:07 蘑菇王国大聪明 阅读(71) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 //函数的值传递 5 template<typename T> 6 void swapValue(T a, T b){ 7 cout<<"值传递函数开始前a = "<<a<<", "<<"b = "<< 阅读全文
posted @ 2021-07-15 09:09 蘑菇王国大聪明 阅读(79) 评论(0) 推荐(0) 编辑
摘要:排序算法比较 阅读全文
posted @ 2021-07-13 08:58 蘑菇王国大聪明 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-07-08 07:58 蘑菇王国大聪明 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2021-07-06 16:08 蘑菇王国大聪明 阅读(71) 评论(0) 推荐(0) 编辑
摘要:作用:只产生一个对象 1 class Yoshi { 2 public: 3 //外界只能通过这种方式调用这一个对象,返回必须是引用 4 static Yoshi& getInstance(){return yoshi;} 5 //setup(); 6 private: 7 //两个构造函数 8 Y 阅读全文
posted @ 2021-06-24 16:48 蘑菇王国大聪明 阅读(98) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示