Why this code doesn't comile on VC 7.0? (gcc compile it)
The idea is that the Item class should have a handle to itself, but the handle type is known only by the Conteiner class (so if i'd like to chage a conteiner I dont need to chage Item)
Is any wy to solve this?
Code:#include <list>
using namespace std;
template <class R>
class Item {
public:
typedef typename R::I_handle handle;
void SetHandle(handle h) {a=h;}
handle GetHandle() {return a;}
private:
handle a;
};
struct Item_type
{
template <class R>
struct I_Wrapper {
typedef Item<R> Item;
};
};
template <class I=Item_type>
class Container {
public:
typedef Container<I> Self;
typedef typename I::I_Wrapper<Self>::Item Item;
typedef list<Item> Item_list;
typedef typename Item_list::iterator I_handle;
Item_list items;
};
int main()
{
Container<> a;
Container<>::Item i;
Container<>::Item i1;
i.SetHandle(i1.GetHandle());
a.items.push_back(i);
}