随笔分类 - C++
关于内存及其相关
摘要:s32k-iMX8平台XRCE-DDS的搭建 1. 引言 XRCE-DDS简述 XRCE-DDS是可以在资源受限的MCU运行的DDS,在MCU侧运行客户端,通过代理服务参与DDS通信。 使用范围 本文将描述整个XRCE-DDS在GEN2平台的搭建过程,包含SOC侧imx8上运行xrce-dds的an
阅读全文
摘要:适用于用共通的接口处理文件和由文件组成的文件夹等类似情形,把个体和集合做相同的处理 #include "stdafx.h" #include <vector>#include<iostream>using namespace std; class company {public: company(s
阅读全文
摘要:class Element{public: Element(string str) :m_name(str) {} virtual void accept(visitor * pVist) = 0; string getName(void) { return m_name; }private: st
阅读全文
摘要:Cstring因为<cstring>提供的一系列api如strcpy等均已‘\0’结束,所有C-字符串已‘\0’结尾。 char a[5] = {'a','b','c','d','i'}; //not a CString char b[5] = {'s','r','s','x','\0'}; //
阅读全文
摘要:主要目的是命令与接受者的解耦,使得程序的可扩展性增强 UML类图: commamd 到 invoker 类之间应该是聚合的关系,上面没画对,懒得改了。 class lift{public: lift(){}; ~lift(){}; void up(void) { std::cout<<"lift g
阅读全文
摘要:策略模式包含如下基本要素,策略基类,继承于基类的不同算法,包含策略引用的环境(context)角色 class vehicle;class vehicle{public: vehicle(){}; ~vehicle(){}; virtual void showName()=0;};class bik
阅读全文
摘要:cmakeLists.txt编写 1.cmake的最低版本设定 cmake_minimum_required(VERSION 2.8) 2.项目名 project(test) 3.生成文件类型设置 add_executable(demo demo.cpp) # 生成可执行文件 add_library
阅读全文
摘要:原文 from https://www.cnblogs.com/zhengAloha/p/8665719.html #include <stdio.h>#include <stdlib.h>#include <string.h>#include <semaphore.h>#include <pthr
阅读全文
摘要:From <TCP IP网络编程> socket通信的整个过程可以比喻是电话机通信 server: #include<WinSock2.h>int main(int argc, char* argv[]){ WSADATA wsaData; SOCKET hServSock,hClntSock; S
阅读全文
摘要:from https://blog.csdn.net/zzyczzyc/article/details/82935467 #include<algorithm>#include<deque>class player{public: player(string name,int score):mNam
阅读全文
摘要:标准IO库 流与文件对象 对应标准IO库,对文件的读写操作都是围绕着流(stream)进行的 流(文本流或者二进制流)主要是指一种逻辑上的概念,它提供或存储数据。产生数据的叫输入流,消耗数据的叫输出流。流的概念使我们不再关注具体细节和设备本身,是一个抽象的概念 缓冲 标准IO库提供缓冲的目的是尽可能
阅读全文
摘要:原文地址:https://blog.csdn.net/Hu_weichen/article/details/80820728 自己输入跑了一下: #include <vector>#define NULLKEY - 32768class HashTable{public: HashTable(int
阅读全文
摘要:原始代码from: https://blog.csdn.net/Hu_weichen/article/details/80599994 自己写了下: class BTNode{public: BTNode(){} ~BTNode(){} void frontTraverse(void); void
阅读全文
摘要:想了想这个问题,自己写了写,之前百度了个答案,思想基本类似 #include <vector>#include <map> class point { public: point(int x0,int x1):x(x0),y(x1){}; ~point(){}; int getX() const {
阅读全文
摘要:code from <UNIX 高级编程第二版> 一个进程中的所有线程都可以访问该进程的组成部件,如文件描述符和内存。 pthread_t的数据类型表示线程ID func1. pthread_t pthread_self(void) 返回线程ID func2. int pthread_create(
阅读全文
摘要:要得到某个结果,可以有很多种方式,算法就是为了寻找一条最快的方式。 而评判其好坏的标准就是时间复杂度。 O(1): 我们把执行一次的时间复杂度定义为O(1) sum = a +b; cout << sum <<endl; O(n): for(int i = 0; i < n ;++n) { //do
阅读全文
摘要:不连续的存储结构 包含n个节点,每个节点包含数据域和指针域,指针域指向下一个节点 下述链表指单链表。。 头结点只有指针域,是整个链表入口,相关的遍历查询都需要从头指针开始,头结点数据域没有意义为一个随机值 #include "stdafx.h"#include <stdio.h>#include<i
阅读全文
摘要:当我们通过普通的构造函数构造出一个对象之后,用这个对象去初始化另一个新建的对象,如这种: test a(1); test b = a 或者test b(a) 这两种 还有这种 test & gettestObject() 则需要调用拷贝构造函数,如果我们没有显式的声明一个拷贝构造函数,系统会生成一个
阅读全文
摘要:观察者模式:定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新 我们每天都要根据天气来做一些事情 #include "stdafx.h"#include <stdio.h>#include<iostream>#include <string.h>#
阅读全文
摘要:简单工厂模式: typedef enum{ A, B} productType;class product{public: product(){}; ~product(){}; virtual void show()=0;};class productA : public product{publi
阅读全文

浙公网安备 33010602011771号