What is Class :: *

I am studying SFINAE (replacement failure - no) I found an example of this on the site,

template<typename T> class is_class { typedef char yes[1]; typedef char no [2]; template<typename C> static yes& test(int C::*); // What is C::*? template<typename C> static no& test(...); public: static bool const value = sizeof(test<T>(0)) == sizeof(yes); }; 

I found a new int C::* signature on line 5. At first I thought it was operator* , but I suppose this is wrong. Please tell me what it is.

+7
c ++
source share
1 answer

int C::* is a pointer to a member of class C whose type is int .

Example:

 struct C { C () : a(0), b(0) {} int a; int b; }; int main() { int C::*member1 = &C::a; int C::*member2 = &C::b; C c1; c1.*member1 = 10; // Sets the value of c1.a to 10 c1.*member2 = 20; // Sets the value of c1.b to 20 } 
+6
source share

All Articles