"The
The usual use is to write it at the very top of your .h/.cpp files to include other header files like (Windows.h, iostream, cstdio, etc..) to use the what is defined inside in your .h/.cpp file.
The unusual use is to use it to initialize a data-structure like arrays by including a text file that contains the array initialization data between the array initializer list parentheses – e.g XX XXX[] = { <HERE> }. This is is illustrated in the sample program below. The same concept can be used to initialize an array of any dimension.
// main.cpp #include <cstdio> #include <Windows.h> struct Person { char *pName; unsigned Age; unsigned Height; char Gender; }; // Declare and initialize a 1D array of Persons structs using PersonTableData text file // #include "PersonsTableData" will be expanded at COMPILE TIME to the content of PersonsTableData file Person PersonsTable[] = { #include "PersonsTableData"
View original post 73 more words
0 Responses to “Unusual C++ use of #include”