I am using VS 2008.

I'm having problems with specifying a "forward declaration". The class with it in compiles okay, but when the compiler meets a "gcnew xClass();" to instantiate an instance, the compiler "crashes" with a fatal error C1001h in compiler file 'mscl.cpp' line 1441.

my class starts -

#pragma once
using namespace System;
generic<class K, class V>
where K : IComparable

ref class xClass
{
ref struct bNode; //*** Needed to overcome the forward reference ***
ref struct kNode
{
K key;
V value;
kNode^ rLink;
bNode^ dLink;
kNode(K Key, V Value)
{
key = Key;
value = Value;
}
};
ref struct bNode
{
bNode^ parent;
int count;
kNode^ rLink; //*** THIS LINE CAUSES THE CRASH ***
bNode^ dLink;
};
...etc.
};

When I swap the struct blocks round its always the 2nd block's reference to the first block that causes the problem.

If I change the 'kNode^ rLink;' to 'Object^ rLink;' it compiles, but takes an age to do it! devenv.exe seems to go into a loop and lock up the system 100%. I've got to force the MSVC to via with ctrl-alt-del.

It seems that the compiler gets into an endless loop with this circular cross-reference. If I break it by removing either rLink in bNode, or dLink in kNode (and the forward ref line) the compier works okay.

Steve.