Problem declaring data member in a class of a template class

Hey guys, I think it would be alot easier to show you rather than explain what's happening.

Class code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class eResource
{
public:
      template <class derived>
         class Attribute
      {
      public:
	 class attribute
	 {
         private:
            vector <unsigned char>
               values;
            static map <string, int>
               maps;
         public:
            static int test;  //This is what I'm trying to define

            unsigned char& operator[] (int index)
            { return values[index]; }
            unsigned char& operator[] (string str)
            { return values[ maps[str] ]; }
         };

         string name;
         string description;
         attribute attributes;
      };

      class Tile:
         public Attribute <Tile>
      {

      };
   }
};

Defining:
int eResource::Attribute<eResource::Tile>::attribute::test;

Receive these error in codeblocks:
|18|error: 'class eResource::Attribute<eResource::Tile>' is not a valid type for a template constant parameter|
|19|error: 'attribute' in namespace '::' does not name a type|

Mind my lacking C++ terminology:
Attribute is using recursive derivation (templates) to create multiple parent instances of a single object, so static data members can be sliced into portions. In order for me to access (set/get) values, it needs to be defined.

I find the whole defining part quite messy, hard to get my head around.. Any help would be helpful.
Last edited on
You've got an extra } in line 34.
In order to define the static attribute
1
2
template<class T>
int eResource::Attribute<T>::attribute::test = 0;
If you want to specialize
1
2
template<>
int eResource::Attribute<eResource::Tile>::attribute::test = 42;
Topic archived. No new replies allowed.