Suppose we have two classes Foo and Bar. We can declare the Foo class and use its methods as following:
#include"foo.h"
Foo foo
class Bar{
Bar(){
foo.method1();
}
}
And we have the forward declaration, which stands to declare the Foo class as following:
#include"foo.h"
class Foo
class Bar{
Bar(){
}
}
What are the main differences between the two declartions, and when the forward declaration is prefered to the normal declaration?