
c++
文章平均质量分 67
c++
又是这货
这个作者很懒,什么都没留下…
展开
-
C++实现高并发内存池
内存池原创 2022-09-02 18:48:15 · 389 阅读 · 1 评论 -
C++11
文章目录交替打印奇偶数const_cast交替打印奇偶数#include <condition_variable>void thread_print(){ std::mutex mtx; condition_variable c; int n = 100; bool flag = true; thread t1([&]() { int i = 0; while (i < n) { unique_lock<mutex> lock(mt.原创 2022-05-09 17:32:50 · 505 阅读 · 0 评论 -
继承、多态
文章目录继承虚函数继承class parent{ int i; protected: int x;public: parent(){ x = 0; i = 0; }void change() { x++; i++; }void display();};class son :public parent{public: void modify();};void parent : : display() { cout << "x=" << x <&l.原创 2022-04-30 22:43:41 · 421 阅读 · 0 评论 -
哈希Hash
文章目录unordered_set961.在长度2N的数组中找出重复N次的元素349.两个数组的交集387.字符串中的第一个唯一字符闭散列方法 -- 线性探测unordered_set#include<iostream>#include<vector>#include<unordered_set>#include<set>#include<time.h>using namespace std;void test_time()..原创 2022-02-26 21:22:17 · 407 阅读 · 0 评论 -
map和set
文章目录setmapset#include<iostream>#include <set>#include <map>#include <string>using namespace std;void test_set(){set<int> s1; s1.insert(3); s1.insert(2); set<int>::iterator it1 = s1.begin(); while (it1 != s..原创 2022-01-14 14:43:24 · 195 阅读 · 1 评论 -
日期---
文章目录Date.cppDate.hTest.cpp#include<iostream>using namespace std;class Date{public: //获取一个月中的天数 int GetMonthDay(int year,int month); //构造函数,不要在你的声明和定义中同时写入缺省值 Date(int year, int month, int day); //拷贝构造函数 Date(const Date& d); //== bo..原创 2021-12-20 22:45:50 · 202 阅读 · 0 评论 -
string、 vector
string str;//支持+=,以\0结束,和c语言更好的配合,专有的字符串比较大小,更好的结合字符串的使用方式vector<char> vstr;//面对的是cahr int……%%vector<int> v(10,0);//10个0int arr[10] = {0} ;v[0] = 10;//本质:函数调用,返回的是:返回值对象的别名,赋值给别名,引用,出了作用域返回对象还存在,返回对象:指向vector的第0个位置的值//vector在栈,vector指向的空间原创 2021-09-25 11:25:03 · 150 阅读 · 0 评论 -
stringvector题
string—题917. 仅仅反转字母给定一个字符串 S,返回 “反转后的” 字符串,其中不是字母的字符都保留在原地,而所有字母的位置发生反转。输入:"ab-cd!"输出:"dc-ba!"class Solution {public: bool isLetter(char ch){ if (ch >= 'a' && ch <= 'z') return true; if (ch >= 'A'&& ch <= 'Z') r原创 2021-09-22 22:43:16 · 122 阅读 · 0 评论 -
类与对象-
上课-日期类的实现Date.cpp#include "Date.h"int Date::GetMonthDay(int year, int month){ static int daysArray[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int days = daysArray[month]; if (month == 2 && ((year % 4 == 0 && year原创 2021-09-17 13:42:40 · 175 阅读 · 0 评论