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: 
While curious why would you do this, general note is that you must ***expose to user an interface that cannot be used wrong***. Guts go private:

```
struct Foo
{
public:
    void callme()
    {
        func1();
        func2();
    }

private:
    ... func1(...);
    ... func2(...);

};

int main()
{
    Foo f;
    f.callme();
}

```

If you need to enforce one time initialization of objects, do it in constructor:

```
struct Foo
{
public:
    Foo()
    {
        func1();
    }

    func2(...);
private:
    ... func1(...);
};

int main()
{
    Foo f; // func1() called automagically
    f.func2();
}

```

Designing class interfaces, you must allways think about the worst things: users never read documentation, users always forget to call `foo.initialize()`, users always forget freeing memory and it leaks, etc.
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