【c++程序】关于operator
来源:互联网 发布:下载民间小调软件 编辑:程序博客网 时间:2024/05/18 00:52
/********************************************************//**************---About 符号的重载-------**************//**************---Author: Tibruce Zhao-----**************//**************---Date: 2015/10/18------***************//********************************************************/ #include<iostream>using namespace std; class F{int n;int d;public:F(int n=0,int d=1):n(n),d(d){}void print(bool newline=true);void input();int getn() const {return n;}int getd() const {return d;}friend istream& operator>>(istream& in,F& f);//有元,可以访问私有成员};//void operator>>(istream &in,int& n){}istream& operator>>(istream& in,F& f){char c;in>>f.n>>c>>f.d;return in;}ostream& operator<<(ostream& out,const F& f){out<<"分子"<<f.getn()<<'/'<<"分母"<<f.getd();return out;}int main(){F a,b;int n;cin>>a>>b;//cin.operator>>(a); operator>>(cin,a)//cin>>n; //operator>>(int& __n); operator>>(cin,n)cout<<a<<b; //cout.operator<<(a); operator(cout,a);return 0;}
0 0
- 【c++程序】关于operator
- operator.c
- C++Operator
- 关于C++ 的 operator
- 关于operator new重载
- 关于assignment operator
- 关于operator=
- 【ThinkingInC++】59、关于operator->
- 关于 ::operator new
- 关于operator 的用法
- 关于C语言程序
- 关于C语言程序
- 【c程序】关于宏
- 关于new operator 和operator new
- 关于new operator, operator new, placement new
- C + + operator precedence list
- [C++]C++ Operator Precedence
- c语言 cast operator
- OGRE初级教程总结
- 工作10年,一点想法
- BZOJ1831
- 【IOS 开发学习总结-OC-54】★★ios开发UI 控件——UINavigationBar 与UINavigationController
- 不要只替换一个类
- 【c++程序】关于operator
- 双向栈的初始化,压栈,出栈
- 自定义类为什么要实现Serializable
- 输入一个浮点小数, 将其按4舍5入转换成整数, 并显示
- linux 安装环境 记录
- html验证码生成
- 存储过程和函数的区别
- 1037. 在霍格沃茨找零钱(20)
- sizeof 问题总结