摘要: 重载操作符,只是另外一种调用函数的方法和表现方式,在某些情况它可以让代码更简单易读。注意不要过度使用重载操作符,除非它让你的类更简单,让你的代码更易读。1语法如下:其中友元,关键字不是必须的,但是当你需要读参数类的内部变量时候,声明就需要加上friend.friend Money operator +(const Money & amount1,const Money& amount2); friend bool operator ==(const Money & amount1,const Money& amount2); friend Money opera 阅读全文
posted @ 2013-10-28 21:44 joey周琦 阅读(432) 评论(0) 推荐(0) 编辑
摘要: const简单介绍:1不再使用c中的#define,c++默认不给const定义的变量分配内存,所以它默认的是仅本文件可以看到该变量(即internal linkage),const int bufisze;如果工程中的文件看见,就要明显的写出关键字extern,即,此时编译器会给它分配内存。extern const int bufisze = 100;另外:extern const int bufsize;//只是声明不是定义const int bufsize=10;//必须加上如此定义// int bufsize=1;!error//bufsize=1;erroconst buf;//错误 阅读全文
posted @ 2013-10-28 21:18 joey周琦 阅读(432) 评论(0) 推荐(0) 编辑