The only way you might call a function before
main
is making it part of the construction of a global (or static) object, e.g.
#include <iostream>
using namespace std;
class A
{
int n;
public:
A(int n):n(n){show();}
void show(){cout << n << endl;}
};
A a(3);
int main()
{
cout << "main" << endl;
}
However, you
fetch
function needs an instance of
List<int>
that is currently scoped by
main
.