struct Entry
{
int Data0;
};
struct ExtendedEntry : public Entry
{
int Data1;
};
I have a simple method waiting for a C-style array pointer for Entry like this
void Calculate(Entry* data, int count);
This method obviously fails when passing the pointer to the ExtendedEntrys array. How to prevent users from doing this?
ExtendedEntry items[50];
Calculate(items, 50);
Not that I was chasing a bulletproof API, I just want to stop me and my colleagues from repeating the same error.
source
share