I have looked at similar queries but I seem to be getting myself lost. I have a simple example, so please consider the following:
#include <iostream>
using namespace std;
class Animal
{
public:
Animal() {cout << "Animal" << endl;}
};
class Cat : public Animal
{
public:
Cat() {cout << "Cat" << endl;};
};
int main()
{
Cat c;
return 0;
}
When the program runs, it displays
Animal
Cat
My question is now this: Which constructor is actually called first. Is Cat() called and then Cat() calls Animal() before it executes its contents OR does the compiler/program look at Cat(), see that it's an Animal() and calls Animal() first then Cat()?