I have a .h file inside I have a function that uses a Struct/Class Constructor for the default argument.
It appears on the declaration end like answered here : Where to put default parameter value in C++?
Function declaration
vector<UINT_PTR> scan(const ScanOptions& scan_options = ScanOptions());
Struct definition
struct ScanOptions {
ScanOptions()
{
//Use some Windows.h functions here to find values
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
start_address = sysinfo.lpMinimumApplicationAddress;
end_address = sysinfo.lpMaximumApplicationAddress;
}
UINT_PTR start_address;
UINT_PTR end_address;
};
It is answered here that:
Private structures for that file should go in the .c file, with a declaration in the .h file if they are used by any functions in the .h .
Should struct definitions go in .h or .c file?
There doesnt seem to be a way to declare a struct only to forward declare it?
C++, how to declare a struct in a header file
So do I just keep the declaration and definition of my struct inside my header or is there another recommended way?
I mean I dont really care that its global since its working and I dont think its gonna lead to problems but I really wanna know.