As a practical matter, the first way includes the contents of the file it references, and the compiler has to grind through the contents of that file - which may be a significant amount of code. In the second case, the compiler only handles the single line of code. The end result is decreased compilation time if you use the second method.
Whether this is worthwhile is questionable. I typically include <Qt/GUI> in my headers, and despite the enormous amount of code this hauls in, my compilation times are still very quick, even on large projects. The total gain by using the second method would only be a matter of a few seconds, at best.
Also, note that in the second case you can only declare variables of the type specified; you have no access to their internal structure, because the compiler knows nothing about it. So it isn't as useful when you need to reference some internal class member.
Try it both ways. If you see a significant improvement in compilation speed with the second, and don't run up against it's limitations, go ahead and use it.
Bookmarks