c++
msforever
这个作者很懒,什么都没留下…
展开
-
C++中的类拷贝构造函数和模板拷贝构造函数
类(包括模板类)构造函数是真实的构造函数;然而模板构造函数,其实质是模板函数。两者不能混为一谈。在一个模板类中,构造函数和模板构造函数同时存在时,优先调用构造函数。只有当确切符合模板构造函数的接口时,才调用模板构造函数。编译器永远不会把模板构造函数视为构造函数,即使客户没有自己定义拷贝构造函数,编译器也会生成一个默认的拷贝构造函数,这种情况同样存在于拷贝赋值函数和模板拷贝赋值函数。请看下面的例...原创 2010-09-11 20:53:22 · 622 阅读 · 0 评论 -
(zz)编译与使用Qt4,Visual Studio Express 2008
一、Qt版本我现在用的是4.5.2。好像前段时间4.6出来了。。一直想找个轻量、好用、简单、快速的UI库。实话实说Qt也不是很满足我的要求,不过还是比较好用的,运行库打包10m左右,加壳压缩一下3~5m左右,也还是在接受范围之内。二、Qt安装下载的opensource的Qt安装包。在win32平台下自带mingw,用gcc编译。可以配合Eclipse+CDT开发。。不过开发...原创 2010-10-14 22:35:56 · 102 阅读 · 0 评论 -
#define总结 (网上资料汇集)
1. 定义简单的常数:定义常量,便于修改(切不可在后面加上分号!) #define N 1000 等效于 const int N = 1000; 但略有不同,define只是简单替换,而不是作为一个量来使用.2. 定义简单的函数:注意多使用括号define可以像函数那样接受一些参数,如下:#define max(x,y) (x)>(y)?(x):(y);这个...原创 2010-10-30 08:06:14 · 105 阅读 · 0 评论 -
stdcall cdecl fastcall thiscall naked call的具体含义
在C语言中,假设我们有这样的一个函数:int function(int a,int b)调用时只要用result = function(1,2)这样的方式就可以使用这个函数。但是,当高级语言被编译成计算机可以识别的机器码时,有一个问题就凸现出来:在CPU中,计算机没有办法知道一个函数调用需要多少个、什么样的参数,也没有硬件可以保存这些参数。也就是说,计算机不知道怎么...原创 2010-10-30 18:54:24 · 99 阅读 · 0 评论 -
VC: error LNK2019:unresolved external symbol *** referenced in function ***的解决方案
当头文件中声明了一个函数,但是在相应的源文件中却没有对该函数进行定义,则会出现为“解决的外部符号”(unresolved external symbol )错误。另外,当一个函数调用了外部的一个库文件中的函数,但是在当前project的properties中并没有将所依赖的(dependent)库文件包含进来时,也会出现这种错误。 综上,当一个solution在linkin...原创 2010-10-30 21:13:39 · 97 阅读 · 0 评论 -
零星笔记,待整理
[code="c++"] //用 getline 函数从输入读取整行内容。然后为了获得每行中的单词,将一个 //istringstream 对象与所读取的行绑定起来,这样只需要使用普通的 //string 输入操作符即可读出每行中的单词。 string line, word;// will hold a line and word from input, rect...原创 2010-11-01 13:00:39 · 103 阅读 · 0 评论 -
在VS2010下配置VC++ Directories
1:可以 在“class View” 面板 -> 右键 工程 -> 属性 -> VC++ Directories ; 但是这种方法配置的事当前工程; 2:任意建立一个MFC工程, “Property Manager” 面板 -> Debug | Win32 (Release| Win32) -> Microsoft.Cpp.Win32.use...原创 2012-08-07 08:29:22 · 225 阅读 · 0 评论 -
LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSV
LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)LIBCD.lib(dbgheap...原创 2012-08-07 09:20:07 · 406 阅读 · 0 评论 -
error LNK2005 and error LNK2019
error LNK2005 and error LNK2019error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: double & __thiscall std::vectorcode generation-> runtime library "Mul...原创 2012-08-09 23:08:52 · 215 阅读 · 0 评论 -
strcat 内部实现
[code="c++"]char * strcat(char * dest, const char * src){ char *tmp = dest; while (*dest) dest++; while ((*dest++ = *src++) != '\0') ...原创 2010-09-21 00:43:07 · 420 阅读 · 0 评论 -
deep copy & shallow copy
A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The p...原创 2010-09-15 19:27:11 · 80 阅读 · 0 评论 -
reinterpret_cast的本质(转)
先看看下面的代码:[code="c++"]#include using namespace std;void main() { int i = 875770417; cout原创 2010-09-14 23:15:24 · 96 阅读 · 0 评论 -
两种自动类型转换:构造函数与operator
如果有两个对象:one, two, 要想把one转换成为two,有两种方法:在one在定义operator two() const函数在two在增加two(const one&)构造函数一般只能使用其中一种情况,而不能两种一起使用。operator:#include using std::cout;using std::endl;class two {...原创 2010-09-12 02:23:05 · 119 阅读 · 0 评论 -
C++中操作符operator的两种用法
1.operator overloadingC++可能通过operator 重载操作符,格式如下:类型T operator 操作符 (),如比重载+,如下所示template class A{public: const T operator + (const T& rhs) { return this->m_ + rhs; }pr...原创 2010-09-12 02:23:53 · 191 阅读 · 0 评论 -
c++ library and resource List
1,前言 无数次听到“我要开始学习C++!”的呐喊,无数次听到“C++太复杂了,我真的学不会”的无奈。Stan Lippman先生曾在《C++ Primer》一书中指出“C++是最为难学的高级程序设计语言之一”,人们常将“之一”去掉以表达自己对C++的敬畏。诚然,C++程序设计语言对于学习者的确有很多难以逾越的鸿沟,体系结构的庞大,应接不暇并不断扩充的特性……除此之外,参...原创 2010-09-13 18:56:45 · 377 阅读 · 0 评论 -
C++著名程序库的比较和学习经验
1、C++各大有名库的介绍——C++标准库2、C++各大有名库的介绍——准标准库Boost3、C++各大有名库的介绍——GUI4、C++各大有名库的介绍——网络通信5、C++各大有名库的介绍——XML6、C++各大有名库的介绍——科学计算7、C++各大有名库的介绍——游戏开发8、C++各大有名库的介绍——线程9、C++各大有名库的介绍——序列化10、C++各大有...原创 2010-09-13 19:30:29 · 98 阅读 · 0 评论 -
C++提供了四种新的类型强制
static_cast const_cast reinterpret_cast dynamic_cast 1)staic_cast静态强制; [code="java"][/code]不能在无关的指针之间进行static类型强制 [code="c++"]class CAnimal { //... public: CAnimal(...原创 2010-09-13 23:13:08 · 107 阅读 · 0 评论 -
[转]C++ reinterpret_cast,const_cast等 显式类型转换总结
[code="c++"]#include int main(void) { //reinterpret_cast //将一个类型指针转换为另一个类型指针,这种在转换不修改指针变量值数据存放格式 //只需在编译时重新解释指针的类型,他可以将指针转化为一个整型数但不能用于非指针的转换 double d=9.3; double* pd ...原创 2010-09-13 23:23:03 · 133 阅读 · 0 评论 -
内存对齐的规则以及作用
首先由一个程序引入话题:[code="c++"]1 //环境:vc6 + windows sp2 2 //程序1 3 #include 4 5 using namespace std; 6 7 struct st1 8 { 9 char a ;10 int b ;11 short c ;12 };13 1...原创 2010-09-14 00:14:12 · 85 阅读 · 0 评论 -
C++ 经典书籍
下载地址:http://www.51cnnet.net/directoryC++ in a Nutshell free ebook downloadCryptography in C and C++ free ebook downloadMore Exceptional C++ free ebook downloadC++ Cookbook free ebook downl...原创 2010-09-14 16:18:22 · 252 阅读 · 0 评论 -
const 与static 关键词在c 和 c++中的作用
一.C语言中的const const是C语言中保留的一个关键字,它用来限定一个变量是只读的,即不可变的。程序中使用const可以在一定程度上提高程序的健壮性,但是程序中使用过多的const,可能在对代码的阅读时增加一定的难度。1)用const修饰一般变量 注意在C语言中,用const修饰的变量必须在声明时进行初始化(用来修饰函数的形参除外); ...原创 2012-08-11 11:49:02 · 212 阅读 · 0 评论