Quote: "Structs are literally the exact same as classes apart from the different default access levels."
I just spent the better part of an afternoon chasing a bug because of sloppy code creation and a significant difference with pointers to structures and classes. They appear to be handles differently (at least in VC++2008) one to the other when compiled. An observation that was noted.
If we create SOME.CPP:
struct SomeStructure
{
.........;
.........;
.........;
.........;
.........;
.........;
};
SomeStructure *pUserStructure;
****NOTE: I did not instantiate a structure for that pointer*****
I can compile the code fine, and from within that SOME.CPP file there is no problems getting to the individual structure members.
ie: "pUserStructure->......" works correctly with no problems (this surprised me).
One can create a SOMEsecond.CPP:
extern SomeStructure *pUserStructure;
The code still compiles fine but whenever one tries to access that structure from within this second file with "pUserStructure->......", the code still compile fine, but the EXE file will throw an exception and crash when it gets to that code.
Without instantiating "pUserStructure = new SomeStructure;", the code fails(this did not surprise me).
If one does the exact same procedure, but using a class instead of a structure,
even without instantiating, the above example will compile and execute with no problems at all (I nearly fell off my chair).
There is more difference between classes and structures and how they are handles than just difference in default access levels. What it is I do not know, but under very strange conditions they are handled differently.