I am viewing cocos2dx c++ source code and in it there are many places where they use
class Classname;
e-g in CCNode.h line 43
class CCCamera;
Classname is name of the class they are using and later I dont see any reference to that I never seen this before.
I would like to know what that means.
C mostly uses functional/structural programming instead of implementing Object Oriented Programming as in languages like C++ , Java , Python etc. which use classes .
class classname* is the return type of the function. class classname is an elaborated type specifier.
C Classes A class consists of an instance type and a class object: An instance type is a struct containing variable members called instance variables and function members called instance methods. A variable of the instance type is called an instance.
A class is a user-defined type that describes what a certain type of object will look like. A class description consists of a declaration and a definition. Usually these pieces are split into separate files. An object is a single instance of a class. You can create many objects from the same class type.
This is a forward declaration so that the actual imports occur in the .cpp files instead of the header files. This is a common practice in C++ OOP.
For a good explanation, see this post with a similar question C++ Forward declaration
When you make a forward declaration, you are informing the compiler you intend to use something in advance. The important take aways, as declared in the link above, are that forward declarations break cyclic references and reduce compiler build times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With