Home > Back-end >  About a function pointer and class members do the default values
About a function pointer and class members do the default values

Time:11-10

Excuse me, figure a TypeComparator in the class definition of function Pointers can write like this? If you do that figure 2 default parameters, define the static members can like this? How should write to compile ah?

CodePudding user response:

Have been failed to upload pictures,,,
Figure part code for:
Template
The class TypeComparator {
Public:
Bool equalP (*) (T, T)=this - & gt; Equals : : value | | STD: : is_pointer & lt; T> : : value>;

Template
Bool equals (T t1, t2 T) {
return false;
}
Template<>
Bool equals (T, t1, t2 T) {
Return the t1==t2;
}
};

CodePudding user response:

Classes defined in the static member variables is
The template & lt; Typename T>
The class LinkedList {
Protected:
The static TypeComparator CompHelper;
};

CodePudding user response:

Class member functions are defined in the
Bool contain (T T, bool (* equals). (T, T)=compHelper equalP);
  • Related