标签:c/c++
#include <iostream> #include <stdio.h> using namespace std; class Input { public: //实际重载是右移运算符 Input & operator >> (int &a) { scanf("%d",&a); fflush(stdin);//去掉回车 return *this; } Input & operator >> (float &a) { scanf("%f",&a); fflush(stdin);//去掉回车 return *this; } //重载输出运算符 friend ostream & operator <<(ostream &os,Input &v); }; ostream & operator <<(ostream &os,Input & v) { os << v.m_pData->id ; return os; } Input In; int main(int argc, char* argv[]) { int a; float b; In >>a>>b; cout << a << "," << b <<endl; getchar(); }
标签:c/c++
原文地址:http://9233403.blog.51cto.com/9223403/1967106