#include <iostream>
using namespace std;
class Student
{
private:
int n;
public:
Student(int n1)
{
n=n1;
}
void display()
{
cout<<n<<endl;
}
};
int test(int a)
{
return(1);
}
int main()
{
Student stud(2);
int (*p1)(int);
p1=test;
p1(2);
void (Student::*p)();
p=&Student::display;
(stud.*p)();
return 0;
}
为什么倒数第六行的p1(2);与写成(*p1)(2)时等价的,而(stud.*p)();却不能写成(stud.p)();?
麻烦解释一下其中的机理,感谢!