开发者

question about templates [closed]

开发者_JAVA技巧 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜