There is a function that we would like only one other function to be the sole caller of:

```
void bar(){

}

void foo(){

}

void baz(){

}

```

All three functions are located within the same class. We would like foo() to be able to call bar(), but not allow baz() to call bar().

So far, this answer seems to suggest the solution is to either have a lambda function within a function, or to create an struct / anonymous struct within a function.

[Can we have functions inside functions in C++?](https://stackoverflow.com/questions/4324763/can-we-have-functions-inside-functions-in-c)

Is there a way we can achieve our goal, without having to move bar() within foo() ie - without having to create a lambda or struct within foo ?

**This is just a technical experiment to explore whether it is possible or not - it is not about what we "should" be doing, but rather to simply see if it is possible.**