2012年5月25日

摘要: int *y = new int; *y = 10; 或者 int *y = new int (10); 或者 int *y; y = new int (10); 一维数组: float *x = new float [n]; 在Borland C++中,当new 不能分配足够的空间时,它会引发(t h r o w)一个异常xalloc (在except.h 中定义)。可以采用try - ca... 阅读全文
posted @ 2012-05-25 21:28 Buttonwood 阅读(164) 评论(0) 推荐(0) 编辑
 
摘要: 传值函数:int Abc(int a, int b, int c){ return a+b+b*c+(a+b-c)/(a+b)+4;}模板函数:template<class T> T Abc(T a, T b, T c){ return a+b+b*c+(a+b-c)/(a+b)+4;}形式参数的用法会增加程序的运行开销类型T 的复制构造函数把相应的实际参数分别复制到形式参数a,b和... 阅读全文
posted @ 2012-05-25 20:47 Buttonwood 阅读(147) 评论(0) 推荐(0) 编辑