C/C++
文章平均质量分 55
gezhiwu1213
这个作者很懒,什么都没留下…
展开
-
VSCode +CMake +Gtest实现象棋功能
一、工程目录.├── build├── CMakeLists.txt├── code│ ├── inc│ └── src├── googletest-release-1.8.1│ ├── appveyor.yml│ ├── build│ ├── BUILD.bazel│ ├── ci│ ├── CMakeLists.txt│ ├── configure.ac│ ├── CONTRIBUTING.md│ ├── .gitignore│...原创 2021-06-25 21:59:50 · 483 阅读 · 0 评论 -
vscode工程调试
一、没有cmake文件目录结构:.├── build├── CMakeLists.txt└── code ├── inc └── src原创 2021-06-19 17:11:00 · 401 阅读 · 1 评论 -
gtest工程
执行脚本:#!/usr/bin/env bash# install gtests script on mac# https://gist.github.com/butuzov/e7df782c31171f9563057871d0ae444a#usage# chmod +x ./gtest_installer.sh# sudo ./gtest_installer.sh# Current directory__THIS_DIR=$(pwd)# Downloads the 1.8.转载 2021-06-19 15:24:56 · 362 阅读 · 0 评论 -
gtest-coverage
https://paul.pub/gtest-and-coverage/转载 2021-06-11 19:36:39 · 1881 阅读 · 0 评论 -
C++ 内存管理之重载operator new 和operator delete
当我们在C++中使用new 和delete时,其实执行的是全局的::operator new和::operator delete。首先我们来看一个简单的例子。class Foo{...}Foo* pf = new Foo;delete pf上面的代码底层执行的是什么呢?首先new包含两阶段的操作。(1)首先调用::operator new分配内存 (2)调用Foo::Foo() 构造对象内容然后是delete也分两部分的操作。(1)首先调用Foo::~Foo()将对象析构 (2)调转载 2021-04-20 20:54:25 · 377 阅读 · 0 评论 -
C++工具网站
一、编码查询http://www.cplusplus.com/reference/cstring/memcmp/二、编码规范https://wiki.sei.cmu.edu/confluence/display/cplusplus/2+Rules?src=contextnavpagetreemode原创 2021-03-26 20:03:30 · 92 阅读 · 0 评论 -
关键字mutable
一、含义 mutable “可变的”、“易变的”,与const相反二、作用 突破const限制,被const修饰的变量,将永远处于可变的状态,即使在一个const函数中。如果让类的成员函数不改变对象的状态,一般这个成员函数会声明成const,但是如果需要在const函数中修改一些跟类无关的数据成员,那么这个数据成员就应该被mutable修饰。三、示例#include <iostream>using namespace std;class TestMuta...原创 2021-03-26 19:57:59 · 102 阅读 · 0 评论 -
Google 开源项目风格指南 (中文版)
https://zh-google-styleguide.readthedocs.io/en/latest/原创 2020-12-25 19:39:51 · 136 阅读 · 0 评论 -
编写一个C程序,用于打印九九乘法表
#includevoid main(){ int i,j; for(i=1;i { for(j=1;j { printf("%d×%d=%d\t",i,j,i*j); } printf("\n"); }}运行效果图如下:转载 2015-07-18 22:52:31 · 9557 阅读 · 0 评论 -
c语言程序设计(第1讲)关键字
c语言有32个关键字,分别为:auto break case char const continue default do double else enum extern float for goto if int long register return short signed static sizeof struct swtich typedef union unsigned void vo转载 2015-07-14 21:47:30 · 643 阅读 · 0 评论 -
如何给数组添加字符串
添加头文件#include “string.h”例如定义一个数组unsigned char xxx[20];给它赋值一个字符串“hello”,可以这样写:strcpy((char*)xxx,”hello”);//把”hello”赋值给xxx数组如果想在xxx原有的字符串后面添加一个数组,如添加 “World!”,可以这样写:strcat((char *)xx转载 2015-07-14 20:09:15 · 4350 阅读 · 0 评论