Here my code and IDE is DEV C ++ 11
#include<iostream>
using namespace std;
class A{
public:
int a=15;
};
class B:public A
{
};
int main(){
int A::*ptr=&B::a;
int B::*ptr1=&A::a;
int B::A::*ptr2=&B::a;
int B::A::*ptr3=&A::a;
}
I read programming languages - C ++, and I know what kind of &B::athere int A::*, but I do not understand why these three lines will pass compilation. And the strangest thing for me is the syntax int B::A::*, what is the meaning of this? I'm just new to C/C++, so please bear with my weird question.
source
share