i have following code
#include <iostream>
#include <utility>
using namespace std;
namespace rel_ops{
template<class t>bool operator!=(const t& x, const t& y){ return !(x==y);}
template <class t>bool operator>(const t& x,const t& y){ return y<x;}
template <class t>bool operator <=(const t& x,const t& y){ return !(y<x);}
template <class t> bool operator>=(const t& x,t& y) { return ! (x<y);}
}
int main(){
int x,y;
cin>>x>>y;
return 0;
}
i have question how implement it in main function? how implements its operators in main function
Here is an explanation and a nice example:
http://www.cplusplus.com/reference/std/utility/rel_ops/
You just need to add:
using namespace rel_ops;
Note that rel_ops is already defined in std. You do not need to redefine this namespace and its contents in your code. To use the definition already present in std, you use just:
#include <utility>
using namespace std::rel_ops;
精彩评论