I've got the following two classes in C#:
public class MyFirstClass : IMyFirstClass
{
MySecondClass mySecondClass;
public MyFirstClass(IMySecondClass mySecondClass)
{
this.mySecondClass = mySecondClass;
}
public MyFirstClass() : this(new MySecondClass()){}
}
public class MySecondClass : IMySecondClass
{
MyFirstClass myFirstClass;
public MySecondClass(IMyFirstClass myFirstClass)
{
this.myFirstClass = myFirstClass;
}
public MySecondClass() : this(new MyFirstClass()){}
}
You'll notice that when the default constructor for either of these classes is instantiated that the system will crash because of the infinite instantiations that need to take place.
Is there an official term that is used to describe this problem?