自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(100)
  • 收藏
  • 关注

原创 Qt常用小技巧

(1)用于调试程序。QMessageBox::information(0, tr(""), tr(""));//用于调试程序

2015-07-03 12:30:47 626

原创 source insight 4.0 鼠标点击,高亮选中

2019-09-26 13:49:27 1539

原创 windows 编译boost

1. 解压文件夹。  2. 运行bootstrap.bat。3. 运行b2.exe。

2017-05-26 21:41:27 390

原创 QT 常见错误总结

(1)出现以下错误可能是 pro文件中的module没有说明1>moc_QView2D.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: static struct QMetaObject const QWidget::staticMetaObject" (__imp_?staticMetaObject@QWidget@

2017-05-21 19:06:50 659

原创 VS2015 设置出插件 highlight all references 效果

效果是鼠标点击某个变量后高亮出所有该变量。工具 --> 选项 --> 环境 --> 字体和颜色 --> 显示项 中找到“突出显示的引用”, 把“项背景”颜色更改,如浅绿色。“项前景”不变或为自定义颜色。

2017-04-04 12:09:03 1624 1

原创 VS 错误处理

1. c1xx : fatal error C1027: Inconsistent values for /Ym between creation and use of precompiled header使用预编译头文件时出现的错误问题。Properities -> C/C++ -> Command Line -> Additional Opitons: /Zm500 (把此值改小)

2017-03-14 22:09:45 1071 2

原创 windows批处理文件设置环境变量,包含路径、库目录等

.bat文件内容如下:@set "PATH=/yourPath;%PATH%"@set "INCLUDE=/yourPath;%INCLUDE%"@set "LIB=/yourPath;%LIB%"

2017-03-07 16:27:24 2492 1

转载 VS 设置在Release模式下调试的方法

设置在Release模式下调试的方法:1.工程项目上右键 -> 属性2.c++ -> 常规 -〉调试信息格式    选  程序数据库(/Zi)或(/ZI), 注意:如果是库的话,只能(Zi)3.c++ -> 优化 -〉优化            选  禁止(/Od)4.连接器 -〉调试 -〉生成调试信息 选  是 (/DEBUG)

2016-12-25 20:44:54 3184

原创 read .txt file

/*------------------------------------------------- Read .txt file-------------------------------------------------*/void ReadTxt(std::string fileStr){ std::ifstream file(fileStr); std::string s

2016-11-06 20:37:17 629

转载 notepad++ 设置轻量级编译器

(一)设置环境变量新增用户环境变量INCLUDE、LIB,修改用户的Path:在命令行中执行以下命令,把(Program Files)替换为你的目录,比如我的是C:\Program Files (x86)。注意原PATH变量最后是否有分号。setx LIB "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib;C:\Pr

2016-10-22 16:37:11 1635

原创 只能堆/栈上创建对象

(一) 只能堆上#include class A{public: static A* Create() { return new A(); } void Destory() { delete this; } protected: A(){}; ~A(){};};int main(){ A *a = A::Create(); print

2016-10-22 10:35:15 264

原创 malloc/free用法

int *p = (int*) malloc(sizeof(int));if(p!=NULL) // do something// ...if(p!=NULL){ free(p); p=NULL;}

2016-10-19 10:21:15 248

原创 二分法查找时间复杂度计算

查找数据长度为N,每次查找后减半,第一次   N/2...第k次   N/2^k最坏的情况下第k次才找到,此时只剩一个数据,长度为1。即 N/2^k = 1查找次数 k=log(N)。

2016-10-07 16:40:00 14043 2

原创 字符数组

#include #include #include int main(){ char *a = "abcd"; char b[] = "abcd"; printf("%s\n",a); printf("%d\n",sizeof(a)); // 4 printf("%s\n",b); printf("%d\n",sizeof(b)); // 5 return 0

2016-10-05 14:34:48 239

原创 strcpy 拷贝问题

destination长度小于source时会出现问题,使用时需要小心。int main(){ char s1[] = "123456789"; char d1[] = "123"; strcpy(d1,s1); printf("%s\n",s1); printf("%s\n",d1); printf("0x%08x\n",&s1); printf("0x%08x

2016-10-05 13:12:37 995

原创 使用itoa函数输出二进制格式

可以得到输入数的二进制、16进制格式。/* itoa example */#include #include int main (){ int i; char buffer [33]; printf ("Enter a number: "); scanf ("%d",&i); itoa (i,buffer,10); printf ("decimal: %s

2016-10-05 10:21:25 2779

原创 std::vector存放类的指针避免拷贝构造函数的调用

#include #include using namespace std;class A{ public: A() { printf("A()\n"); } ~A() { printf("~A()\n"); } A(const A& other) { printf("copy\n"); }};int main(){ A *a = ne

2016-09-26 19:48:25 2181

原创 查找100以内的素数

#include using namespace std;int main(){ int a[101] = {0}; for(int i=0; i<101; ++i) { a[i] = 1; } for(int i=1; i<101; ++i) { for(int j=2; j<101; ++j) { if( (i!=j) && (0==i%j) )

2016-09-26 17:20:52 556

原创 判断程序是c还是c++编译的

int main(){#ifdef __cplusplus printf("%s", "c++");#else printf("%s", "c");#endif return 0;}

2016-09-23 19:28:26 461

原创 C++ exception

throw , try, catch 使用 int x1 = 0, x2 = 1; try { if(x1!=x2) { throw runtime_error("Number must be equal !"); } } catch(runtime_error& ex) { cout << ex.what() << endl; }

2016-08-29 21:57:57 389

原创 linux eclipse编译程序

eclipse链接到库的设置如果库的名字为libXyz.so,路径为:/home/user/myDireclipse设置如下:g++ -L/home/user/myDir -lxyz myprog.cpp -o myprog注: -L 链接库的路径        -l  链接库的名字

2016-08-27 11:09:08 452

原创 linux dirent.h 使用

#include #include #include #include #include void print_usage(void){ printf("Usage: programe_name dir_name\n");}int main(int argc,char *argv[]){ DIR * dp; struct dirent *filename; if (

2016-08-24 21:49:06 1859

原创 linux 查看gcc版本,支持C++11

查看gcc版本gcc --version命令行编译g++ -std=c++11 -o main main.cpp

2016-08-24 21:05:24 77816 1

原创 Visual Studio 统计代码行数

Ctrl + Shift + F: 打开查找对话框。查找内容:^:b*[^:b#/]+.*$查找范围可选择:只统计打开的文档。只勾选使用正则表达式。查找文件类型可以选择相应的文件类型。

2016-05-01 11:11:30 429

原创 Linux 编译VTK

用CMake配置工程,选择生成Makefile,进入vtk-bin文件夹下打开终端,输入make,即可编译。如果提示缺少X11下的文件,则运行以下命令更新系统库:apt-get install build-essentialapt-get build-dep vtk

2016-04-20 10:44:04 1110

原创 编译VXL的问题

VXL (the Vision-something-Libraries) is a collection of C++ libraries designed for computervision research and implementation.编译会出现的错误:(1)BUILD_SHARED_LIBS 选项要是false。该库暂时不支持编译动态库。(2)出现: error

2016-04-15 09:17:22 1415 1

原创 利用Visual Studio 自带工具查询lib 或者 dll 文件是32位还是64位

以vs2010为例,进入以下目录C:\Program Files\Microsoft Visual Studio 10.0\VC\bin打开控制台窗口,运行vcvars32.bat,设置vs运行环境输入以下命令进行查询dumpbin /headers path其中path为lib或dll文件的路径,并且加上该文件的名字。输出的信息即可查询文件位数。

2016-04-14 21:36:01 2835

原创 itk 读取图像,两种格式之间转换

/************************************************************************ 控制台运行程序 输入: 程序名称 读取图像文件名 保存图像文件名 输出: 保存另一种类型的图像 功能: 图像在jpeg和bmp两种格式之间互换**************************************

2016-04-11 21:02:31 4856

原创 C++ 虚函数

虚函数用于实现多态,核心理念就是通过基类访问派生类定义的函数。由于编写代码的时候并不能确定被调用的是基类的函数还是哪个派生类的函数,所以被成为“虚”函数。虚函数只能借助于指针或者引用来达到多态的效果。#include using namespace std;class A{public: virtual void Print() { cout <

2016-04-09 14:06:43 230

原创 C++ 访问范围说明符

基类的private成员:基类的成员函数基类的友元函数基类的public成员:基类的成员函数基类的友元函数派生类的成员函数派生类的友元函数其他函数基类的protected成员:基类的成员函数基类的友元函数派生类的成员函数可以访问当前对象的基类的保护成员

2016-04-09 11:05:34 410

原创 C++ 流输入输出运算符重载

#include #include #include using namespace std;class Complex{public: Complex(double r=0, double i=0):real(r), image(i) {}; friend ostream& operator<< (ostream &os, const Complex& c);

2016-04-07 22:44:02 1849

原创 C++ 可变长数组类的实现

涉及到构造函数,析构函数,复制构造函数,运算符=, [ ] 的重载等。#include using namespace std;class CArray{public: CArray( int s = 0 ); CArray( CArray &a); ~CArray(); void push_back(int i); CArray& operator= (const

2016-04-07 09:13:21 4351

原创 C++ 赋值运算符=重载

#include using namespace std;class String{public: String():str(NULL) { } ~String() { if(str) delete[] str; } const char * c_str() { return str; } char * operator= (co

2016-04-04 22:53:35 1176

原创 C++ 静态成员

(1)静态成员变量本质上是全局变量,哪怕类的一个对象都不存在,类的静态成员变量也是存在的。(2)静态成员函数本质上是全局函数。(3)目的是将和某些类紧密相关的全局变量和全局函数写到类的里面,看上去更像是一个整体,更易于维护和理解。

2016-04-04 16:01:27 247

原创 C++ 查看类的内存大小

#include using namespace std;class Demo{private: int x; double y;};int main(){ cout << sizeof(Demo) << endl; cout << sizeof(char) << endl; cout << sizeof(int) << endl; cout <<

2016-04-04 15:49:36 1433

原创 C++ 析构函数

关于析构函数的调用顺序可以参看代码:#include using namespace std;class Demo{public: Demo(int i) { id = i; cout << "id = " << id << " constructed." << endl; } ~Demo() { cout << "id = " << id << "

2016-04-04 15:38:44 297

原创 C++ 类型转换构造函数

目的:实现类型的自动转换特点:(1)只有一个参数,该参数不是该类的引用;(2)不是复制构造函数。

2016-04-04 14:54:20 277

原创 C++ 构造函数

#include using namespace std;class Test{public: Test(int n) { cout << "1" << endl; } Test(int n, int m) { cout << "2" << endl; } Test() { cout << "3" << endl; }};int main()

2016-04-04 14:31:16 257

原创 C++ 类对象的内存分配

对象的内存空间对象的大小 = 所有成员变量的大小之和。每个对象各有自己的存储空间。

2016-04-04 11:28:33 485

原创 c++ 函数缺省参数

定义函数的时候可以让最右边的连续若干个参数有缺省值,那么调用函数的时候,若相应位置不写参数,参数就是缺省值。void func( int x1, int x2 = 2, int x3 = 3) {}func(10); // equal to func(10,2,3)func(10,8); // equal to func(10,8,3)func(10,,8); // error

2016-04-04 10:46:35 304

空空如也

空空如也

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

TA关注的人

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