c ++有趣的函数定义

cmu*_*use 3 c++ function

我检查了RDcode的代码.我遇到了一个定义的函数,我不明白.你能帮我这个代码吗?

template <typename T>
   class argless {
   public:
     argless(const T& c) : container(c) {}; // i dont understant this line.
     bool operator() (unsigned int v1,unsigned int v2){
       return container[v1]<container[v2];
     }
     const T &container;
   };
Run Code Online (Sandbox Code Playgroud)

Oli*_*rth 8

它是一个构造函数,它接受a的引用const T,并container用它初始化成员变量.

  • @Oli:请将"const引用改为T"改为"引用const T" (2认同)