_neverToSayFail

2012年8月27日

运算符重载

摘要: 1.C++提供了单目运算符和二元运算符的重载,这样可方便同类成员函数对不同数据类型的操作,返回值操作类型也可能不同,View Code //add.hpp#ifndef _HHADD#define _HHADDclass add{public: int temp; //int b; add() { temp=0; }};#endif//addHPP.hpp#include "add.hpp"add operator+(add inputfi, int b){return add(inputfi.temp+b);};//main.cpp#include "add.h 阅读全文

posted @ 2012-08-27 22:03 安心走完 阅读(150) 评论(0) 推荐(0) 编辑

导航