- 博客(22)
- 资源 (9)
- 收藏
- 关注
转载 动态库的制作和使用
Linux动态库生成以及调用Linux下动态库文件的文件名形如libxxx.so,其中so是 Shared Object 的缩写,即可以共享的目标文件。在链接动态库生成可执行文件时,并不会把动态库的代码复制到执行文件中,而是在执行文件中记录对动态库的引用。程序执行时,再去加载动态库文件。如果动态库已经加载,则不必重复加载,从而能节省内存空间。Linux下生成和使用动态库的步骤如下...
2020-02-20 14:13:21
690
原创 c++回调函数
#include "stdafx.h"#include <vector>#include<string>#include<sstream>#include<iostream>#include<iomanip>#include<string>#include<stack>#include<m...
2020-01-14 10:49:11
171
原创 单例设计模式
class InitSingleton{public: ~InitSingleton() { std::cout << "destructor called!" << std::endl; } InitSingleton(const InitSingleton&) = delete; InitSingleton& operator=(con...
2020-01-11 17:14:03
117
转载 linux 有名管道用法示例代码
发送端:#include "name_fifo.hpp"#include <unistd.h>#include <stdlib.h>#include <fcntl.h>#include <limits.h>#include <sys/types.h>#include <sys/stat.h>#include...
2019-12-27 14:05:02
319
原创 二叉树的中序遍历
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla...
2019-11-18 20:54:16
188
原创 归并排序---
归并排序的图解:以下图片转载自:https://www.cnblogs.com/chengxiao/p/6194356.html总结起来,关键点有2步骤:1.确定递归的终止条件2.写好合并函数#include <stdio.h>#include <string>#include <iostream>void m...
2019-11-03 21:48:51
125
原创 linux共享内存示例
#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <sys/shm.h>#include <string>struct shared_use_st{ uint32_t written;//作为...
2019-10-28 22:20:23
260
原创 进程之间条件变量的同步
#include <boost/interprocess/managed_shared_memory.hpp>#include <boost/interprocess/sync/interprocess_mutex.hpp>#include <boost/interprocess/sync/interprocess_condition.hpp>#incl...
2019-10-26 15:08:50
475
原创 多线程编程(1):锁的使用
互斥锁(mutexlock):最常使用于线程同步的锁;标记用来保证在任一时刻,只能有一个线程访问该对象,同一线程多次加锁操作会造成死锁;临界区和互斥量都可用来实现此锁,通常情况下锁操作失败会将该线程睡眠等待锁释放时被唤醒自旋锁(spinlock):同样用来标记只能有一个线程访问该对象,在同一线程多次加锁操作会造成死锁;使用硬件提供的swap指令或test_and_set指令实现;同互斥...
2019-09-23 20:34:01
224
原创 linux下的gtest环境初步使用
1、先到gtest官网下载一个稳定的gtest包;2、下载完之后解压如果是linux用户,有很多文件可以删掉,比如MSVC是针对Windows平台使用的……注意:上面build文件夹是自己新建的(下一步)。3、新建一个build文件夹,在build文件夹执行cmake ..4、进入make文件夹,执行make命令,编译用例文件5、此时生成新的用例二进制文...
2019-09-19 10:29:09
782
原创 VS2017 出现0xc00007b的解决办法
对于初学者,有时候好不容易安装好了庞大的VS,等写完代码准备“hello world”的时候,却出现了以下错误提示,然后各种搜索仍然不能解决问题。解决办法:1)邮件 项目属性:注意上面是 debug的设置,如果是released的话,需要配置为MT...
2019-08-26 15:30:26
3204
原创 为什么最好将基类的析构函数定义为虚函数
下面看一个例子:#include "stdio.h"#include<cstring>/***************************************/ class school { public: school(const char *st_name); ~school(); private: char* scho...
2019-06-01 21:59:22
542
原创 linux 下无名管道的用法:
#include "stdio.h"#include <stdlib.h>#include <unistd.h>#include <string.h>typedef unsigned int uint32;void main(){ char buf[]="this is master data"; printf("buf data le...
2019-05-18 23:31:09
530
原创 linux环境下创建进程
#include "stdio.h"#include <unistd.h>void main(){ printf("hello word\n"); pid_t pid = fork(); int test1=0; if(pid<0) { printf("creat process faild\n"); } else if(...
2019-05-18 16:42:31
251
原创 C++ 创建内存块 Python读取内存块
经过各种折腾,终于搞定了这个奇葩需求:首先来看 c++文件创建一个内存块服务端客户端分别如下://#include "stdafx.h"#include <windows.h>#include <iostream> using namespace std; #define BUF_SIZE 4096 int main(){ // 定义共享数据 ...
2019-05-10 01:36:58
1273
转载 c++中有些重载运算符为什么要返回引用
文章转自:https://www.cnblogs.com/codingmengmeng/p/5871254.html事实上,我们的重载运算符返回void、返回对象本身、返回对象引用都是可以的,并不是说一定要返回一个引用,只不过在不同的情况下需要不同的返回值。那么什么情况下要返回对象的引用呢?原因有两个:允许进行连续赋值 防止返回对象(返回对象也可以进行连续赋值(常规的情况,如a...
2019-04-29 17:00:55
1762
原创 VS2017创建单元测试基本步骤
1、新建一个VS项目:备注:本例中创建的是win32 的控制台工程 创建工程时,推荐在属性设置中,c/c++ ——>代码生成配置为下图: 2、新项目调试通过之后,右键解决方案,选择:新建项目,添加--->测试项目 3、在测试项目上右键添加引用,选择刚才构建的工程4、在源工程上右键,选择属性--...
2019-04-23 19:45:35
12513
8
转载 虚函数调用原理:
转自https://www.cnblogs.com/malecrab/p/5572730.html1. 概述简单地说,每一个含有虚函数(无论是其本身的,还是继承而来的)的类都至少有一个与之对应的虚函数表,其中存放着该类所有的虚函数对应的函数指针。例:其中:B的虚函数表中存放着B::foo和B::bar两个函数指针。 D的虚函数表中存放的既有继承自B的虚函数B::foo,又有重写(...
2019-04-23 11:09:29
564
原创 python3 html 解析
来看一段来自糗百的网页文件,文件名为test.html。<head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><meta content="chrome=1,IE=edge" http-equiv="X-UA-Compatible"/><meta con...
2019-03-23 01:29:36
1922
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人