cstring.h
#pragma once #include<iostream> #include<string> using namespace std; class cstring { private: string s; public: cstring(); ~cstring(); friend ostream &operator<<(ostream &out,const cstring &a); friend istream &operator>>(istream &in,cstring &a); cstring operator+(const cstring &a); void operator=(const cstring &a); bool operator<(const cstring &a); bool operator<=(const cstring &a); bool operator>(const cstring &a); bool operator>=(const cstring &a); bool operator==(const cstring &a); bool operator!=(const cstring &a); };cstring.cpp
#include"cstring.h" cstring::cstring() { } cstring::~cstring() { } ostream &operator<<(ostream &out,const cstring &a) { out<<a.s; return out; } istream &operator>>(istream &in,cstring &a) { getline(in,a.s); return in; } cstring cstring::operator+(const cstring &a) { cstring z; z.s=s; z.s+=a.s; return z; } void cstring::operator=(const cstring &a) { s=a.s; } bool cstring::operator<(const cstring &a) { if(s<a.s) return true; return false; } bool cstring::operator<=(const cstring &a) { if(s<=a.s) return true; return false; } bool cstring::operator>(const cstring &a) { if(s>a.s) return true; return false; } bool cstring::operator>=(const cstring &a) { if(s>=a.s) return true; return false; } bool cstring::operator==(const cstring &a) { if(s==a.s) return true; return false; } bool cstring::operator!=(const cstring &a) { if(s!=a.s) return true; return false; }main.cpp
#include"cstring.h" void main() { cstring s,x; cin>>s>>x; if(s>x) cout<<"OK"; system("pause"); }