answersLogoWhite

0

A forward declaration is simply a declaration of an identifier that will be defined at a later point during compilation. It is quite common to separate declarations from their definitions using header files (.h) and source files (.cpp). The header essentially contains all the forward declarations of all the definitions contained in the source file.

It is also common practice to use forward declarations when a header contains pointers to a type, rather than references. If it includes references, then you must include the header file for those references, but if they are pointers then you only need a forward declaration of the type (before it is used) and the actual header that contains the full declaration can be included in the source file instead.

User Avatar

Wiki User

13y ago

What else can I help you with?

Continue Learning about Engineering
Related Questions

In c plus plus Who tells the compiler that a specific class will be declared later in the program?

A forward declaration. However forward declarations can only be used when the class is used as a pointer or reference prior to its definition, otherwise it must be defined before it is used. class A; // forward declaration class B { A& data; // reference to class that has yet to be defined }; class A {}; // definition


In c plus plus are local declarations visible to the function in a program?

If you declare a variable inside of any fuction (except main) it will not be available to other functions.


What is an ordered list of data structure using c plus plus?

An ordered list of data in any programming language is simply a sorted array or list. In C++ this can either mean a sorted array, vector, list or forward list.


What is the purpose of the header file io.h in c plus plus?

The header, io.h, is part of the standard C library and contains declarations for file handling and I/O functions. The file has no practical purpose in C++; it is only included because it was required prior to C++ standardisation. However, it can be used when writing C-style programs and libraries in C++.


What is the mean c plus plus in machine code?

It is used to distinguish between the C or C++


What is the function of stdlibh in c language?

It contains useful declarations.


What is a backwards L forward C backward C forward L mean in numbers?

In numbers, a "backwards L" typically represents the number 7, a "forward C" represents the number 3, and a "backward C" represents the number 6. A "forward L" can represent the number 1. Therefore, the sequence "backwards L forward C backward C forward L" translates to 7, 3, 6, 1.


In C plus plus Interface is also known as?

I guess you mean Java, there is no interface in C++.


What is iosteram in c plus plus?

The <iostream> include file is a header file that contains the prototype declarations of functions that provide the basic input/output mechanisms in C++. The <iostream> header file sets up the objects that initialize the basic input/output pathways, cout and cin.


How do you rectify braces expected error in c plus plus language?

This type of error indicates you've omitted braces where braces were expected. For instance, class declarations must be enclosed within curly braces, as must function definitions.


What does c mean in y equals mx plus c?

c is any constant value


How do you begin a page of C plus plus coding?

It depends whether you are writing a header or a source file. Generally you will begin with the header, and this should always begin with a header guard: // file: my_header.hpp #ifndef _MY_HEADER_HPP_ #define _MY_HEADER_HPP_ //... // header code goes here // ... #endif _MY_HEADER_HPP_ Although the opening header guard should always be placed first, it's a good idea to precede the header guard with a multi-line comment briefly explaining the purpose of the header and its contents, as well as the author's contact details and any required copyright notifications. The header code will include any other required headers as well as any required forward declarations, followed by its own declarations. You may also include definitions for those declarations, however its generally best to keep implementation details separate from the declarations. The only exceptions are when declaring class templates, which must be completely defined in the header, or when defining implicit inline functions. The corresponding source file must include the header file, along with any other header files for its forward declarations, before defining the implementations of the header's undefined declarations. Other files that require those definitions need only include the corresponding header file.