I have a Om::Value class, and an Om::ValueList class. ValueList needs to include OmValue.h as it has, for example, Value operator[](int index) method.
But I'm trying to add a ValueList toList() method to Value, which means I have a circular dependancy. But I noticed that if I forward declare ValueList at the top of OmValue.h, GCC is then allowing me to use ValueList as a return type (not a reference or pointer):
class ValueList;
class Value
{
public:
// snip
ValueList toList() const; // thought this would throw a "not defined" error?
};
I thought this was not allowed since the compiler would need to know the size of ValueList? Is this non-standard or undefined or something GCC is allowing through an extension, or is this perfectly valid standard C++?