Question: How can I ensure that a specific method is called, at compile time?

For example, suppose I have an object with 2 methods:

```
struct Foo
{
   ... func1(...);
   ... func2(...);
};

```

and I want to ensure that func1 is called before any calls to func2, i.e.:

```
int main()
{
   Foo f;
   ...
   f.func1(...);
   f.func2(...);
   f.func2(...); // and so on
}

```

but I want to generate a compile error if I do something like that:

```
int main()
{
   Foo f;
   ...
   f.func2(...);  // generate a compile error due the fact that func1 must be called first
   f.func1(...);
   f.func2(...); // and so on
}

```

Answer: 
There is no real way to enforce this at compilation time. This is something that the object itself will need to enforce with runtime checks
The compiler can't enforce the order of function calls, since in general that can only be determined at run-time. But it can enforce object initialisation before the object can be used. So the best way to get a compile-time check is to do whatever `func1` does in a constructor - either part of `Foo`'s constructor, or a helper object that you need to create in order to call `func2`.