cplusplus
a119258
这个作者很懒,什么都没留下…
展开
-
c++ NULL、nullptr和数字0的区别
1、NULL、0和nullptr的区别 直接上源码 #include using namespace std; void fun(int){ cout << "hello \n"; } void fun(void*){ cout << "world \n"; } int main(int argc, char *argv[]) { cout << "Hello原创 2018-06-29 11:26:08 · 762 阅读 · 0 评论 -
单例 C++各种实现
#include <iostream> #include <mutex> using namespace std; #if 0 //懒汉,不安全,不是放new对象 class Singleton { Singleton(){} static Singleton * instance; public: static Singleton* getIn...原创 2018-07-03 15:03:52 · 1617 阅读 · 0 评论 -
数组中查找重复数字的问题
题目 在一个长度为 n 的数组里的所有数字都在 0 到 n-1 的范围内。数组中某些数字是重复的,但不知道有几个数字是重复的,也不知道每个数字重复几次。请找出数组中任意一个重复的数字。例如,如果输入长度为 7 的数组 {2, 3, 1, 0, 2, 5},那么对应的输出是第一个重复的数字 2。 要求复杂度为 O(N) + O(1),也就是时间复杂度 O(N),空间复杂度 O(1)。因此不能...原创 2018-07-03 16:41:59 · 509 阅读 · 0 评论 -
C++复习-01
C++复习-01 (想到哪写到哪系列) C++析构函数为什么要写成virtual class Base { public: Base(){cout << "Base" << endl;} ~Base(){cout << "~Base" << endl;} //void print(){cout << "This...原创 2019-03-19 10:56:40 · 180 阅读 · 0 评论 -
Fast-RTPS Ubuntu16.04编译
克隆Fast-RTPS并回滚(我用的这个版本) https://github.com/eProsima/Fast-RTPS.git git checkout f661619b04347e9365445af91ca542dddbce3cf9 安装依赖包 sudo apt-get install openjdk-8-jdk sudo apt-get install gradle 这两个依赖...原创 2019-05-30 13:45:16 · 1859 阅读 · 0 评论 -
Fast-RTPS简单测试
虽然在官方的Github中有不少的例子,但是感觉都挺复杂的,不能很好的理解,所以自己拆解成比较简单的,易于学习理解。我是刚开始学习,一定会有不扫理解有误的地方,希望大家指正 首先编写 .idl 文件,这个文件的主要作用是定义用于发布topic的数据类型 //test.idl struct Test { unsigned long index; string message; }; ...原创 2019-05-31 15:28:36 · 3161 阅读 · 1 评论