Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does `::*` (colon colon star) means in C++? [duplicate]

Tags:

c++

There is a segment of code incomprehensible when my friend was reading this hpp file. Specifically,

  • what does certain formation such as A(B, C), int(int, int), or in this case T(Type::*) means? I've already seen usages such as std::function<int(int, int)>, but still have no idea what int(int, int), alone, means.
  • what does Type::* mean? How can a asterisk mark follows :: directly?
like image 559
CXuesong Avatar asked Jun 12 '18 13:06

CXuesong


1 Answers

::* is used to declare a pointer to a member of class. So in this case, it's pointing to a member of the template type callled Type.

std::function<int(int, int)> is an std::function for holding a method that takes paramters of (int, int), and returns an integer result. (This is an example of the famously complicated C/C++ type declaration syntax).

like image 156
Baldrick Avatar answered Sep 28 '22 08:09

Baldrick