函数参数入栈的方式 --------------------------------------------------------------- 在函数调用过程中,会使用堆栈,这三个表示不同的堆栈调用方式和释放方式。 比如说__cdecl,它是标准的c方法的堆栈调用方式,就是在函数调用时的参数压入堆栈是与函数的声明顺序相反的,其它两个可以看MSDN,不过这个对我们编程没有太大的作用 --------------------------------------------------------------- 调用约定 ... Read More
posted @ 2011-10-06 21:21 jc24 Views(204) Comments(0) Diggs(0)
#include "stdafx.h"#include <WinSock2.h>int _tmain(int argc, _TCHAR* argv[]){ WSADATA wsaData; int Ret; //加载winsock库 第二个参数 用与其加载库版本有关信息填充这个结构。版本2.2 if ((Ret = WSAStartup(MAKEWORD(2,2),&wsaData))!= 0) { printf("wsastartup failed with error %d \n",Ret); return 0; } if(WSA Read More
posted @ 2011-09-21 21:34 jc24 Views(178) Comments(0) Diggs(0)
char[] = "Beorn"; //array of 6 chars编译器会自动在字符串的末尾添加字符0.称以0结尾的字符串为c风格的字符串。所有的字符串常量都是 c风格的字符串。char* pc = "howdy"; // pc points to an array of 6 chars只有字符数组能够通过字符串进行初始化,但所有的数组都能够通过与其类型相匹配的值列表进行初始化。int ai[] = {1,2,3,4,5,6}; //array of 6 intsint ai2[100] = {0,1,2,3,4,5,6,7,8,9}; //the Read More
posted @ 2011-09-15 20:06 jc24 Views(240) Comments(0) Diggs(0)
template <class T> 或 template <typename T>有时称类模板为类型生成器。泛型编程依赖于显示模板参数的形式称为参数化多态(应该是翻译的问题,不像人说的话啊)。面向对象编程那个多态称为专用多态。都称为多态是因为每种类型都依赖于程序员通过一个单一的接口表示一个概念的多个版本。为什么使用模板? 为了灵活性和性能。当编译器编译一个使用模板的代码时,编译器将查看模板以及模板的参数类型。其目的在于获得足够的信息以生产优化代码。编译器试图要求模板必须在他被使用的位置完全定义。因此模板的设计者会试图将模板的定义放置在头文件中。建议:对于将在多个翻译单 Read More
posted @ 2011-09-14 20:46 jc24 Views(211) Comments(0) Diggs(0)
如果一个类只能被用做基类,它就是一个抽象类。“protected ”用于构造函数来的目的是:保证我们不能直接创建其对象,其只有它的派生类可以直接使用。class B{public:virtual void f() = 0;virtual void g() = 0;}B b; //error B is abstracvirtual void f() = 0; 是一个纯虚函数,它必须在派生类中被覆盖. 注意,除非所有纯虚函数都被覆盖了,否则该派生类也是抽象的。class D2:public B{public:void f();};D2 d2; //errror:D2 is abstractcla. Read More
posted @ 2011-09-14 20:14 jc24 Views(161) Comments(0) Diggs(0)
枚举 enumeration 它指定一个值的集合,这些值用符号常量表示,称为枚举常量。enum Month{ jan = 1,feb,mar,apr,may,june,july,aug,sep,oct,nov,dec};如果你让编译器选择值,它赋予每个枚举量的值为上一个枚举量的值加1.不初始化第一个枚举量,编译器从零开始计数。Month m = feb;m = 7; //errorint n =m; //okMonth mm = Month(7); // uncheckedMonth 是一个独立类型,它可以隐式转换成整数,但整型不能隐式转换为Month类型。枚举量的作... Read More
posted @ 2011-09-13 21:58 jc24 Views(159) Comments(0) Diggs(0)
class complex{public: complex(double); //defines double-to-complex conversion complex(double,double); .......}complex z1 = 3.14; //ok convert complex z2 = complex(1.2,3.4);class Vector{ explicit Vector (int){cout << "调... Read More
posted @ 2011-09-10 17:56 jc24 Views(179) Comments(0) Diggs(0)
写一个vector 时候,当写到operator= 时候,总是出现一个运行时错误,如下:Windows has triggered a breakpoint in myVector.exe.This may be due to a corruption of the heap, which indicates a bug in myVector.exe or any of the DLLs it has loaded.This may also be due to the user pressing F12 while myVector.exe has focus.The output win Read More
posted @ 2011-09-09 14:43 jc24 Views(1788) Comments(0) Diggs(0)
double* p0; //uninitialized:likely troubledouble* p1 = new double; //get(allocate)an unintialized doubledouble* p2 = new double(5.5); //get a double initialized to 5.5double* p3 = new double[5]; //get(allocate)5 uninitialized doubles Read More
posted @ 2011-09-09 12:30 jc24 Views(142) Comments(0) Diggs(0)
sizeof 用于用于一个类型名 或 表达式。对一个类型名来说,sizeof给出这种类型对象的大小;对于一个表达式来说,sizeof给出表达式结果的大小。sizeof 结果是一个正整数,sizeof(char) 单元大小被定义为1。 Read More
posted @ 2011-09-09 12:18 jc24 Views(196) Comments(0) Diggs(1)