If a pointer to incomplete class type is passed to delete
, an operator delete
overload may be overlooked.
That's all I got… and to be bitten, you would have to do that yet nothing else in the source file that would cause an "incomplete type" compiler error.
EDIT: Following the lead of the other guys, I'd say the difficulty (may be considered danger) is ensuring that the forward declaration, in fact matches the real declaration. For functions and templates, argument lists have to be kept in sync.
And you need to delete the forward declaration when removing the thing it declares, or it sits around and crufts up the namespace. But even in such cases, the compiler will point at it in the error messages if it gets in the way.
The bigger danger is not having a forward declaration. A major disadvantage of nested classes is that they cannot be forward declared (well, they can inside the enclosing class scope, but that's only brief).