Stupid question.
MFC C++,
I have a few structs that are used everywhere in my program.
I would like to be able to add a function to the struct that clears/initliatzes all the variables.
Is this possible? I have seen something about adding functions to structs before but when I complied i get errors about the function already being defined. Yes, I could make them classes but I would imagine this would be possible as well especially since they are all just data...
Basically what would be ideal would be
Code:
struct MyStruct
{
bool mybool;
double mydouble;
clear();
}
MyStruct::clear()
{
mybool = false;
mydouble = 0.0;
}
and then to intilize I would simple do
MyStruct instance;
instance.clear();