the other day I was searching on github and I came across this game named Pioneer, on file pi.h I noticed a lot of "class X;" statements (where X is "Galaxy","Intro", etc.) here you can see the code. what is it for? and is it good practice? I supossed it has a simple explanation but I could not find anything on the web.
Asked
Active
Viewed 630 times
0
-
2Those are the declarations of the classes, they will be defined later. – David G May 14 '14 at 21:47
-
2[Forward declaration](http://en.wikipedia.org/wiki/Forward_declaration) – Bryan Chen May 14 '14 at 21:49
1 Answers
2
It is called a forward declaration to introduce a type which is being used later on. Without it the compiler doesn't recognize the type and has no clue what to do with it.

zxcdw
- 1,629
- 1
- 10
- 18