Simple example:
You have two header files a.h and b.h. b.h looks like
#ifndef _B_H
#define _B_H
#include "a.h"
class B
{
A* a;
};
#endif
#ifndef _B_H
#define _B_H
#include "a.h"
class B
{
A* a;
};
#endif
To copy to clipboard, switch view to plain text mode
So if you change something in a.h not only this needs to be recompiled, but also b.h. Otherwise (if you use forward declaration) only a.h needs to be recompiled. So yes, you can speed up compilation time.
#ifndef _B_H
#define _B_H
class A;
class B
{
A* a;
};
#endif
#ifndef _B_H
#define _B_H
class A;
class B
{
A* a;
};
#endif
To copy to clipboard, switch view to plain text mode
Also, the compiler has not to include the header file here, which also saves some time, but that is not much...
Bookmarks