#include <iostream>
class A
{
public:
A();
A(int i,double d);
virtual ~A();
public:
friend std::ostream& operator << (std::ostream& fout,A& a);
friend std::istream& operator >> (std::istream& fin,A& a);
private:
int x;
double y;
};
// A.cpp: implementation of the A class.
//
//
#include "stdafx.h"
#include "A.h"
//
// Construction/Destruction
//
A::A()
{
x=1;
y=2.3;
}
A::A(int i,double d)
{
x=i;
y=d;
}
A::~A()
{
}
std::ostream& operator<<(std::ostream& fout,A& a)
{
fout<<a.x<<"#"<<a.y<<"#";
return fout;
}
std::istream& operator>>(std::istream& fin,A& a)
{
char c;
int i;
fin>>a.x>>c>>a.y>>c;
return fin;
}
主意std::的使用,否则会出问题