diem.h
#pragma once #include<iostream> using namespace std; class diem { private: float x,y; public: diem(float=0,float=0); ~diem(void); friend istream &operator>>(istream &in,diem &a); friend ostream &operator<<(ostream &out,const diem &a); };diem.cpp
#include "diem.h" diem::diem(float a,float b) { x=a;y=b; } diem::~diem(void) { } istream &operator>>(istream &in,diem &a) { cout<<"x=";in>>a.x; cout<<"y=";in>>a.y; return in; } ostream &operator<<(ostream &out,const diem &a) { out<<"("<<a.x<<","<<a.y<<")"; return out; }main.cpp
#include"diem.h" void main() { diem x; cin>>x; cout<<x; system("pause"); }