Class forward declaration

what ia meant by class forward declaration?

Hi,
In System Verilog, a forward declaration is a declaration of an identifier (denoting an entity such as a type, a variable, or a function) for which the programmer has not yet given a complete definition. It is required for a compiler to know the type of an identifier (size for memory allocation, type for type checking, such as signature of functions), but not a particular value it holds (in case of variables) or definition (in the case of functions), and is useful for one-pass compilers. Forward declaration is used in languages that require declaration before use; it is necessary for mutual recursion in such languages, as it is impossible to define these functions without a forward reference in one definition. It is also useful to allow flexible code organization, for example if one wishes to place the main body at the top, and called functions below it.

Best Regards,
Chetan Shah
Sr. ASIC Verification Engineer

Product Engineering Services
Software | Embedded | Semiconductor
www.einfochips.com
Frost & Sullivan Company of the Year 2013-14

A forward declaration of a type using a typedef is needed to parse your code. When the compiler comes across an identifier that it has not seen before, it needs to know what that identifier represents in order to parse the code into a meaningful statement. The way the BNF grammar works, the compiler only needs to know is that the identifier represents a type (or class type), but it does not need to know the complete details of the type. A forward typedef declares an identifier as a type in advance of the full definition of that type.

Variables must be declared in full before they are referenced. There is no such thing as a forward variable declaration.

Functions do not need to be declared before referenced because the reference will always contain a set of parenthesis that follow it. There is no such thing as a forward function declaration.