c++ - Add static const data to a struct already defined -


Since the static constant data within a class is actually namespace sugar for a constant, I think

  

Code> Straight A {Float A; Structure B {static const int b = 2; }; };

equals

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

Or something similar. Is this something possible in C ++? It would be useful to be able to tag class definitions for me which I am pulling from third party libraries with such information.

You can not open the straight / class definitions again in C ++ Well, the derivative versions of third party strontics can be made and can add their constants like this:

  Structure My_A: Public A {static const int b = a; };  

Otherwise, you can maintain your constant with the key on a strip type basis.

I like George's idea too.


Comments