#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();
}
重载>>运算符
最新推荐文章于 2023-10-12 01:45:00 发布