JUST WANT A SIMPLE EXPLANATION

Hi there, I have seen a class declaration as in line 3 in the code below and I don't know what this kind of declaration does and how is it different from adding a class as an include directive e.g.#include "someotherclass.h" . I just need a explanation on this please.
1
2
3
4
5
6
7
8
9
#ifndef
#define
class SomeOtherClass;

class MyCurrentClass{
public:
     ...
};
#endif 
That is a forward declaration for a class. It tells the compiler that a class like that exists, but no details about the actual class itself. It is often useful when you have a class relying on another class, but that other class also relies on the first one.
Topic archived. No new replies allowed.