A
Antonio Rivas
Hello again
Lately I find code that declares a class this way:
mainheader.h
------------
#include "myClass.h"
....
class myClass;
.....
This declaration use to be in a header (mainheader.h in this case) that
calls another header in which that class is declared in a standard way,
i.e.:
myClass.h
---------
class myClass {
public:
myClass();
~myClass();
....
}; // myClass
What I don't understand is the purpose of the second empty declaration
of myClass after call myClass.h where is declared for the first time.
What puzzles me most is that there's no safeguard #ifdef to prevent
multiple declarations of myClass and the only reason I see for such
absence is that is legal code that won't throw a multiple declaration
error and that has a reason to make it this way.
An enlightment in this matter will be welcome.
Lately I find code that declares a class this way:
mainheader.h
------------
#include "myClass.h"
....
class myClass;
.....
This declaration use to be in a header (mainheader.h in this case) that
calls another header in which that class is declared in a standard way,
i.e.:
myClass.h
---------
class myClass {
public:
myClass();
~myClass();
....
}; // myClass
What I don't understand is the purpose of the second empty declaration
of myClass after call myClass.h where is declared for the first time.
What puzzles me most is that there's no safeguard #ifdef to prevent
multiple declarations of myClass and the only reason I see for such
absence is that is legal code that won't throw a multiple declaration
error and that has a reason to make it this way.
An enlightment in this matter will be welcome.