Tuesday, November 23, 2010


If Nx represents a namespace and Sx represents a struct or class, all of the following compile:

N1::N2::N3::index = 1;
N1::N2::S3::index = 1;
S1::S2::S3::index = 1;
N1::S1::S2::index = 1;

For the indexes inside a struct, the index needs to be declared as static for the statement to compile. Here is an example:

namespace N1 { namespace N2 {
  struct S3 {static int index;};
    int S3::index = 4;

No comments:

Post a Comment