I have defined a struct within a class as follows:
class my_header {
public:
my_header();
struct add_x {
double operator()() const { return a; }
} add_x;
private:
double a{1.0};
};
When compiling (g++ -std=c++11), I got the following errors:
./my_header.h:19:40: error: use of non-static data member 'a' of
'my_header' from nested type 'add_x'
double operator()() const { return a; }
Is it possible to access private members of the class from the struct defined within the class itself?