自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

kouei

个人学习记录,如果涉及侵权请联系我删除。

  • 博客(22)
  • 收藏
  • 关注

转载 <c> 全局变量可不可以定义在可被多个.C文件包含的头文件中?

转载于:https://blog.csdn.net/lanbing598235681/article/details/6873550全局变量可不可以定义在可被多个.C文件包含的头文件中?最近在学习uC/OS操作系统,对其中定义的全局变量产生了好奇。作者将变量定义在头文件uCOS_II.H中,比如:OS_EXT INT8U OSIntNesting; /* Interrupt nesting level *

2021-10-21 16:46:20 792

原创 <c++> std::optional

#include <iostream>#include <optional>#include <vector>#include <algorithm>#include <set>#include <iterator>int main() { auto optVec = std::make_optional<std::vector<int>>(3, 22); //{22, 22, 22} std

2021-06-08 16:14:21 146

原创 <c++> 一道面试题 反转带符号整数为字符串

#include <iostream>#include <string>#include <algorithm>using namespace std;string To_string_rev(int x){ string x_rev = to_string(x); //cout << "1: " << x_rev << endl; if ('-' == x_rev[0]) { x_

2021-04-29 21:38:42 104

原创 <linux> Sockets:TCP/IP网络基础 学习笔记01

参考:The Linux Programming Interface - A Linux and UNIX System Programming Handbook (by Michael KerrisK)chapter 58 SOCKETS: FUNDAMENTALS OF TCP/IP NETWORKS本章提供一个介绍——计算机网络概念和TCP/IP网络协议。理解这些主题对于有效使用 Internet domain sockets是必要的,这些套接字将在下一章中描述。从本章开始,我们开始提到各种R

2021-04-26 22:37:31 297

原创 Chrome 快捷键

1 标签和窗口同个窗口新建标签:Ctrl + T重新打开最后关闭的标签页:Ctrl + Shift + T打开新建窗口: Ctrl + N打开新的无痕窗口:Shift + Ctrl + N标签内打开 Home 页面:Alt + Home同个标签前进 / 后退:Alt + Right / Alt + Left向左切换标签:Ctrl + Tab / Ctrl + PgDn向右切换标签:Ctrl + Shift + Tab / Ctrl + PgUp关闭标签:Ctrl + W / Ctrl +

2021-04-25 11:43:05 202

转载 <gtest/gmock> 编译时如何把private属性变成public?

本文转载自:https://blog.csdn.net/qq910894904/article/details/38583593在做一些已经写好的代码的单元测试的时候,有时候需要使用到类私有的成员方法或变量。我们不想改动原来的代码,但是又能访问这些私有或者受保护的方法,遇到这种情况怎么办?1.手工替换在原有代码中将private手工替换成public,将protected手工替换成public.这种方法是我们最不想用的方法,因为这需要改变原来的代码。2.宏替换这种方法比较讨巧,但也很好用,我们

2021-04-12 16:44:42 1247

转载 <gtest/gmock> 一个例子gtest

func.h#ifndef FUNC_C#define FUNC_C#ifdef __cplusplusextern "C"{#endif int fac(int nInput);#ifdef __cplusplus}#endif#endif // FUNC_C```\func.c```c#include "func.h"int fac(int nInput) { if(nInput < 0) { return -1; } in

2021-04-12 16:25:23 164

转载 <linux> 删除非法ascii码字符

转载:https://blog.csdn.net/loudyten/article/details/84886254container_of.c:17:1: error: stray ‘\240’ in programcontainer_of.c:17:1: error: stray ‘\302’ in programcontainer_of.c:17:1: error: stray ‘\240’ in programcontainer_of.c:17:1: error: stray ‘\302’

2021-04-11 23:49:21 656

原创 <gtest/gmock> 编译安装

1 下载从官网https://github.com/google/googletest/releases下载,如googletest-1.10.x.zip2 解压到一个目录unzip googletest-1.10.x.zip3 创建编译目录mkdir googletest-1.10.x_building4 创建安装目录mkdir googletest-1.10.x_build5 进入编译目录cd googletest-1.10.x_buildingcmake …/googletest

2021-04-11 23:17:48 336

原创 <linux> ls命令选项 -F

-F:在每个输出项后追加文件的类型标识符,具体含义:“*”表示具有可执行权限的普通文件,“/”表示目录,“@”表示符号链接,“|”表示命令管道FIFO,“=”表示sockets套接字。当文件为普通文件时,不输出任何标识符;...

2021-04-11 12:32:01 663 1

原创 <c> C 库函数 - strncpy()

代码1:/* strncpy 实例 */#include <stdio.h>#include <string.h>int main (){ char str1[]= "To be"; char str2[40]; char str3[40]; /* 拷贝到缓冲区: */ strncpy ( str2, str1, sizeof(str2) ); /* 拷贝 5 个字符: */ memset(str3, '9', sizeof(str3));

2021-04-11 11:52:33 84

原创 <c> C 库函数 - snprintf()

示例代码:#include <stdio.h>int main(){ char str[5]; int ret = snprintf(str, 3, "%s", "abcdefg"); printf("%d\n",ret); printf("%s",str); return 0;}执行结果:7ab 函数说明:C 库函数 - snprintf()C 标准库 - <stdio.h> C 标准库 - <stdio.h&g

2021-04-11 10:02:21 134

原创 <linux> 内存映射学习笔记01 overview

参考:The Linux Programming Interface - A Linux and UNIX System Programming Handbookchapter 49 memory mappings本章讨论使用mmap()系统调用来创造内存映射。内存映射可以用于IPC和一系列其它目的。在深入考察mmap()之前我们从一些基本概念的概述(overview)开始。49.1 Overviewmmap()系统调用创造一个新的内存映射在调用者进程 (calling process’s) 的

2021-04-08 19:37:23 70

原创 <c++> 虚函数的一道面试题

代码:#include <stdio.h> using namespace std; class ITest {public: virtual void test() =0; };class A : public ITest {public: virtual void test() { printf("A. test\n"); } };class B : public A {public: virtual

2021-04-07 16:40:30 76

转载 <c++> STL set自定义比较函数

转载自:https://blog.csdn.net/yasi_xi/article/details/8701220注意:比较函数bool operator() (const CTest& lc, const CTest& rc)后不添加const时在gcc 4.8.5可以通过编译,在目前最新的gcc 11.0.1中不能通过编译,严谨起见,添加了const.代码:#include <set>#include <string>#include <i

2021-04-06 15:51:03 680

转载 <c++> 工厂方法模式讲解和代码示例

转载:https://refactoringguru.cn/design-patterns/factory-method/cpp/example#include <iostream>#include <string>/** * The Product interface declares the operations that all concrete products must * implement. */class Product { public: v

2021-04-04 18:36:47 147

原创 <c++> 静态对象的使用(单例模式)

注意:静态对象中可以包含非静态函数和非静态成员数据。代码:#include <iostream>using namespace std;class Singleton{public: static Singleton& getInstance(int var) { static Singleton instance(var); cout << "called." << endl; return instance; } int

2021-03-31 14:58:44 283

原创 <c++> variadic template Ex.2 实现printf

本文参考了:侯捷老师的c++讲义。#include <iostream>namespace my{void printf(const char* s){ while (*s) { if(*s == '%' && *(++s) != '%') { throw std::runtime_error("invalid format string: missing arguments."); std::cout

2021-03-28 17:19:06 130

原创 <c++> variadic template Ex.1

本文参考了:侯捷老师的c++讲义。#include <iostream>#include <bitset>using namespace std;void printX(){ /*nothing.*/};template <typename T, typename... Types>void printX(const T& firstArg, const Types&... args){ cout << fir

2021-03-28 13:56:51 76

原创 <c++> lambda的capture

本文参考了侯捷老师的关于《C++标准11-14》的讲义。capture的传值和传引用的区别#include <iostream>using namespace std;int main(){ int id = 0; auto f = [id] () mutable { cout << "id: " << id << endl; ++id; }; id = 42; f()

2021-03-28 12:28:47 939

转载 <c++> lambda表达式和函数对象

c++的lambda表达式和函数对象例子1函数对象lambda表达式普通函数例子2例子1函数对象#include <iostream>#include <vector>#include <algorithm>using namespace std;class LambdaFunctor {public: bool operator()(char b) { return b == ' '; }};int main()

2021-03-27 22:15:13 79

原创 ctags和cscope配置

1~/.bashrcexport CSCOPE_DB=/root/cpptest/redis-4.0.11(cscope.out的路径)2~/.vimrcset nuset tags=tags;set autochdir3~/.vim/plugin/cscope_maps.vim部分略去" use both cscope and ctag for ‘ctrl-]’, ‘:ta...

2019-10-07 21:11:45 255

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除