On 23-1-2014 4:48, Guiu Rocafort wrote:
hi list.

I'm taking a look at the janitorial task, specially to the forward
declaration in the wiki[1]. But there is something i'm not sure about.
You can use the forward declaration only if you're using the class as
a pointer and without using any of its functions/attributes ? or is it
just when using the class as a pointer ?

for example, in attribute-rel-util.h, i can get rid of the xml/node.h
include, but sp-css-attr.h doesn't seem to work.

Am I missing something ?

With a forward/incomplete declaration, you can The distinction between "declare" and "define" is important. Not many people know the second rule. So this is fine:

class TypeA;
class TypeB {
    TypeA doSomething(int a, TypeA objecta);
};

Please don't go too crazy with this task. It is best to try to decrease the dependencies of headers that are included often. If file1.h is included by many files, it pays off trying to minimize its dependencies. If file2.h is really only included by a couple of files (which in turn are not included often...), it is not very worthwhile introducing forward declarations in it.
The dependency graphs that doxygen generates are good for determining this.

regards,
  Johan