baramin: (Default)
[personal profile] baramin
You can take the address of a static member if (and only if) it has an out-of-class definition:

class AE {
    // ...
public:
    static const int c6 = 7;
    static const int c7 = 31;
};

const int AE::c7;    // definition

int f()
{
    const int* p1 = &AE::c6;    // error: c6 not an lvalue
    const int* p2 = &AE::c7;    // ok
    // ...
}

(с) http://www.stroustrup.com/bs_faq2.html

March 2017

S M T W T F S
   1234
567 891011
12131415161718
19202122232425
262728293031 

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 26th, 2025 11:51 pm
Powered by Dreamwidth Studios