博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c++ 逗号操作符重载
阅读量:7071 次
发布时间:2019-06-28

本文共 871 字,大约阅读时间需要 2 分钟。

Overload Operator Comma
首先看看think in c++ 给出的一个重载的样例
#include 
using namespace std;class After {public: const After& operator,(const After&) const { cout << "After::operator,()" << endl; return *this; }};class Before {};Before& operator,(int, Before& b) { cout << "Before::operator,()" << endl; return b;}int main() { After a, b; a, b; // Operator comma called Before c; 1, c; // Operator comma called} ///:~
以下是实际使用中用到的样例
#include 
#include
using namespace std;class CClient{public: CClient(){}; ~CClient(){};public: CClient& operator,(string str) { strIpAddr_=str; return *this; } CClient& operator,(int nVal) { nPort_=nVal; return *this; }; bool connect() { //Connect(strIpAddr_,nPort_); cout<<"connect to server "<
输出信息
你可能感兴趣的文章
Algs4-1.1.22以缩进方式打印递归参数
查看>>
*Algs4-1.5.5quick-find的运行时间-(未解决)
查看>>
采蘑菇问题
查看>>
求余数 http://acm.nyist.net/JudgeOnline/problem.php?pid=205
查看>>
每天提高
查看>>
postfix事件
查看>>
android log分析
查看>>
步步为营 .NET 代码重构学习笔记 十三
查看>>
053:Field的常用参数详解:
查看>>
读书笔记之SQL必知必会
查看>>
Jquery获取input表单的内容
查看>>
Paint、Canvas
查看>>
关于读写锁算法的java实现及思考
查看>>
最小堆排序
查看>>
iOS-网络爬虫
查看>>
Matlab实现Butterworth滤波器 分类: 图像处理 ...
查看>>
C# for VS foreach 性能对比
查看>>
C#中类和结构体的区别
查看>>
Silverlight 简单布局
查看>>
float学习
查看>>