![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
文章平均质量分 50
hanfeiyan
这个作者很懒,什么都没留下…
展开
-
C++中的static关键字的总结(转)
C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。1.面向过程设计中的static1.1静态全局变量在全局变量前,加上关键字static,该变量就被定义成为一个静态全局变量。我们先举一个静态全局变量的例子,如下: //Example 1#include <iostre...原创 2018-01-15 14:27:45 · 68 阅读 · 0 评论 -
Ubuntu 16.04 Linux系统内核升级方法(转)
转载地址:http://blog.csdn.net/csdn_duomaomao/article/details/77668946一、查看系统及内核版本命令#查看发布版本号cat /etc/issuelsb_release -a#查看内核版本号uname -sruname -a二、升级内核方法#到 Ubuntu网站http://kernel.ubuntu.com/~kernel-ppa/main...原创 2018-03-03 09:59:14 · 614 阅读 · 0 评论 -
ubuntu 16.04 codeblocks 配置 openmp
( 转载:http://www.voidcn.com/article/p-wwyflsmx-bab.html ) 添加 openmp 编译选项 Setings-->Compiler-->Global compiler settings-->Compiler settings --> Compiler Flags 勾选 Enable the Ope...原创 2018-03-08 09:34:48 · 675 阅读 · 0 评论 -
delete 数组后 指针是否为null
/** \brief 测试 delete 数组指针后,数组指针是否为 nullptr * 测试结果: delete 数组指针后, 数组指针不为 nullptr * * \param * \param * \return * */#include <iostream>using std::cout ;int ...原创 2018-03-21 14:54:08 · 870 阅读 · 2 评论 -
new 数组越界 系统不会报错
/** \brief 测试 数组越界 , 系统是否有报错 * 测试结果: 不报错 * * \param * \param * \return * */#include <iostream>using std::cout ;int main(){ int * ary = new int [100...原创 2018-03-21 15:00:18 · 357 阅读 · 0 评论 -
ubuntu拼音设置
Ubuntu16.04 已经自带pinyin输入法,直接设置即可使用,设置方法: 1、system setting -》language support -> keyboard input method system 选择 fcitx。2、system setting -》 text entry -》,勾选 show current input source in the ...原创 2018-03-25 08:32:41 · 1224 阅读 · 0 评论 -
delete 对象后调用该对象的方法程序不报错
delete 一个对象后,在执行该对象的方法,并不会报错,而返回一个不确定的值。 /*测试 delete MyVector 对象后,执行 is_eof() 函数是否显示已经结束*/#include "vector.h"using uint32 = unsigned int;int main(){ MyVector<uint32>...原创 2018-03-27 10:30:56 · 314 阅读 · 0 评论 -
__gnu_parallel::sort()对空间是否有要求
目的:在使用__gnu_parallel::sort()时,发现改方法对空间好像有要求,所以测试__gnu_parallel::sort()的空间需求。方法: 在4G内存的机器上运行一个大的数据,然后调用__gnu_parallel::sort()排序,看是否能正常运行。结果:该方法确实需要两倍的排序空间#include <iostream>#include ...原创 2018-04-04 15:03:27 · 300 阅读 · 0 评论 -
(转)Linux C++程序进行性能分析工具gprof使用入门
转自https://blog.csdn.net/garfier/article/details/12489953# 性能分析工具软件的性能是软件质量的重要考察点,不论是在线服务程序还是离线程序,甚至是终端应用,性能都是用户体验的关键。这里说的性能重大的范畴来讲包括了性能和稳定性两个方面,我们在做软件测试的时候也是要重点测试版本的性能表现和稳定性的。对于软件测试过程中发现的性能问题,如...原创 2018-04-12 19:35:40 · 190 阅读 · 0 评论 -
整数相乘容易出错实例
////* 1、测试 两个 int32 整数相乘,结果放保存在uint64整数,测试输出结果是否正确 * 2、 * 3、 * * date: 2018-05-25 */#include <iostream>#include <fstream>#include <vector>#include &l...原创 2018-05-24 08:46:46 · 352 阅读 · 0 评论 -
编程错误总结
codeBlocks 中,sizeof() 函数统计错误,需要使用#pragma pack(push, 1)和#pragma pack(pop) 才能统计正确,__attribute__((packed));不正确#if _MSC_VER#pragma pack(push, 1)#endiftemplate<typename T1, typename T2>s...原创 2018-02-08 10:30:45 · 211 阅读 · 0 评论 -
错误示例:字节对齐
#include<vector>#include<iostream>#include<stdio.h>struct student { char c; int age;}__attribute__((packed));//win32 系统中 codeblock 运行结果:为8,char和int换位置后结果为:5 ...原创 2018-02-05 22:51:46 · 231 阅读 · 0 评论 -
static 例子
[code="java"]#includeclass testStatic{ static int a,b; int c; public: testStatic( int _c):c(_c){ } static void output(testStatic & ts); int get();}; int testStatic::a = 1...原创 2018-01-17 09:16:14 · 162 阅读 · 0 评论 -
默认参数的函数
[list][*]函数的缺省参数必须从右向左依次定义,即在模型形式参数的右边不能有缺省的形式参数比如:int fun(int a = 0, int b, int c = 0)[/list][code="c++"]#include//using namespace std; int distance(int x1,int y1,int x2=3,int y2=4);...原创 2018-01-18 14:49:34 · 94 阅读 · 0 评论 -
类模板 示例代码
[code="c++"]#ifndef ARRAY_CLASS#define ARRAY_CLASS#include #include //数组类模板template class Array{public: Array(int sz = 50); //构造函数 Array(const Array& A); //拷贝构造函数 ~Array(vo...原创 2018-01-20 16:40:40 · 212 阅读 · 0 评论 -
vitual 函数
虚函数:通过基类对象指针指向派生类对象,或通过基类对象引用来引用派生类对象[code="c++"]#include #include using std::cout;using std::endl;using std::cin;using std::string;class ex0{ public: virtual string show(){...原创 2018-01-24 10:48:36 · 299 阅读 · 0 评论 -
右值引用与转移语义
转载自《https://www.ibm.com/developerworks/cn/aix/library/1307_lisl_c11/》新特性的目的右值引用 (Rvalue Referene) 是 C++ 新标准 (C++11, 11 代表 2011 年 ) 中引入的新特性 , 它实现了转移语义 (Move Sementics) 和精确传递 (Perfect Forwarding)。它...原创 2018-01-26 14:52:57 · 100 阅读 · 0 评论 -
C++统计代码运行时间计时器(转)
转自http://blog.csdn.net/ap1005834/article/details/53419647 一、前言 这里记下从网上找到的一些自己比较常用的C++计时代码 二、Linux下精确至毫秒 #include <sys/time.h> #include <iostream> #incl...原创 2018-02-05 11:59:53 · 1236 阅读 · 0 评论 -
文件读写代码
#include <iostream>#include <fstream>#include <string>#include <sstream>using std::ifstream;using std::ofstream;using std::string;using std::cout;/* run th...原创 2018-02-05 14:52:52 · 211 阅读 · 0 评论 -
错误示例:包引入顺序
#include<vector>#include<iostream>#include<stdio.h>//如果tuple.h在common.h前面,程序会报错,如果放在后面则正常。//说明包引入有先后顺序,使用时要注意#include "tuple.h"#include "common.h"int main(){ ...原创 2018-02-05 21:51:34 · 307 阅读 · 0 评论 -
__attribute__((packed))详解
转自 http://blog.csdn.net/primeprime/article/details/50646469 1. __attribute__ ((packed)) 的作用就是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐,是GCC特有的语法。这个功能是跟操作系统没关系,跟编译器有关,gcc编译器不是紧凑模式的,我在windows下,用vc的编译器也不...原创 2018-02-05 22:20:26 · 239 阅读 · 0 评论 -
c++11 thread 初始化
class background_task{public: int id; int value; background_task(int _id, int _value):id(_id),value(_value){ output(); std::cout << "initialize.\n"; }...原创 2018-06-06 09:08:26 · 2227 阅读 · 0 评论