mariner
mariner

Reputation: 930

Struct inside C++ 'struct name' does not name a type

A.h

class A {
  enum E {one , two , three};
  struct B {
      char a;
      E num;
  };

  static const B arr[];
}

A.cpp

const B A::arr[] = {
  {'1', one},
  {'2', two},
  {'3', three}
};

I get the following error while compiling: 'B' does not name a type

Upvotes: 1

Views: 271

Answers (1)

juanchopanza
juanchopanza

Reputation: 227370

B is defined in the scope of A, so you need to refer to it by its full name:

const A::B A::arr[] = { ....

Upvotes: 6

Related Questions