class grandfather
{
protected:
int test;
};
class father : grandfather
{
protected:
int foo;
};
class child : father
{
public:
void stuff();
};
void child::stuff()
{
test = 5;
while(test == 5)
{
foo++;
}
}
int main(void)
{
child childObj;
childObj.stuff();
return 0;
}
I’m just curious if this is a safe way to design a program. A friend of mine stated that initializing child in father or grandfather, or father in grandfather will cause an overflow of some sort.
Anyone wanna give their two cents?
Not including the while loop!
There’s nothing wrong with this (I mean, excepting your
whileloop).You have a class, with a parent class, which itself has a parent class. No issue.