I have it:
enum Units { Pounds, Kilos };
struct Configuration
{
const Units units;
const char *name;
inline Configuration(Units pUnits, char *pName) : units(pUnits)
{
name = strdup(pName);
}
inline ~Configuration() { free((void *)name); }
};
I passed one of them to a method like this:
Configuration cc(Kilos, "abc");
cdao->write(cc);
I was getting unpleasant crashes from this until I tried to override the method to take the link:
Configuration cc(Kilos, "abc");
cdao->write(&cc);
And now everything works.
But how can a value structure be screwed with memory?
source
share