C ++ not only supports pointers but also adds new pointers
Int A: * P = & A: m; // member pointer
Usage
A A; A. * P;
A * pA = new A; pa-> * P;
Void (A: * f) () = & A: func; // member function pointer
Usage
A A; (A. * p )();
A * pA; (a-> * p )();
#include "stdafx.h"#include <iostream>using namespace std;class A{public:A():m(0){}int m;void print(){cout << "A print()" << endl;}};int _tmain(int argc, _TCHAR* argv[]){A a;int A::*p = &A::m;void (A::*pf)() = &A::print;cout << a.m << endl;cout << a.*p << endl;a.print();(a.*pf)();system("pause");return 0;}
In addition, I have attached a small knowledge about the number of parameters:
# Include <iostream> using namespace STD; // No parameter in C ++ is the same as void F1 () {cout <"hello" <Endl ;} void F2 (void) {return F1 ();} int main () {// F2 (123); // error: Too returns arguments to function 'void F2 () // In this case, the C parameter does not work, but no error is reported. An error is reported in C ++. In vs, when receiving F1 F2 parameters, F1 (); F2 ();} is reported ();}