I want to use forward declaration of a class in my software, so I can have typedefs
and use them inside the class full declaration.
Smth like this:
The main drawback is everything. Forward declarations are a compromise to save compilation time and let you have cyclic dependencies between objects. However, the cost is you can only use the type as references and can't do anything with those references. That means, no inheritance, no passing it as a value, no using any nested type or typedef in that class, etc... Those are all big drawbacks.
The specific destruction problem you are talking about is if you only forward declare a type and happen to only delete it in the module, the behavior is undefined and no error will be thrown.
For instance:
class A;
struct C
{
F(A* a)
{
delete a; // OUCH!
}
}
Microsoft C++ 2008 won't call any destructor and throw the following warning:
warning C4150: deletion of pointer to incomplete type 'A'; no destructor called
: see declaration of 'A'
So you have to stay alert, which should not be a problem if you are treating warnings as errors.