Add static const data to a struct already defined

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-05-16T21:25:28Z Indexed on 2010/05/16 21:30 UTC
Read the original article Hit count: 197

Filed under:

Since static const data inside a class is really just namespace sugar for constants I would think that

struct A {
    float a;

    struct B {
       static const int b = a;
    };

 };

would be equivalent to

struct A {
    float a;
};

struct A::B {
    static const int b = a;
};

or something similar. Is something like this possible in C++? It would be useful for me to be able to tag class definitions that I'm pulling in from third party libraries with information like this.

© Stack Overflow or respective owner

Related posts about c++