How private are _your_ members?
I like programming in Java. Java has a lot of features that make programming with it very pleasant. For instance, it has a very well documented API and the same code can run on many different operating systems with only small modifications. One feature that I only recently learned about is anonymous inner classes. Once I discovered this feature, it quickly became invaluable. Being able to define a new class, without naming it, anywhere in code allows tight encapsulation of functionality as well as keeping relevant sections of code together. As an example, to handle events generated by pressing a button control in AWT or Swing, I can define an anonymous class right in the method call! This may sound lazy, but this feature allows inner classes to have access to private data that ordinary classes wouldn’t. In the example, my anonymous inner class would have access to any local data, like parameters passed to the method I’m defining the class in.
Now, focus on C++. Its many advantages over Java include small executable size and high-speed code. One feature sorely lacking, though, is the style of anonymous inner classes that Java supports. In C++, in order for an inner class to access the private data of an outer class, the inner class must be a friend of the outer class. In order to be a friend, it must be named, therefore, anonymous inner classes in C++ have severely restricted functionality. As I write this, it feels that, without garbage collection support built into the language, this feature isn’t possible. In C++, local data is deallocated as soon as it goes out of scope unless you allocate it from the heap (either using *alloc or new), and memory allocated from the heap is never automatically deallocated, so supporting this feature without memory management would cause memory leaks. Even so, when working on Aldahar, many situations have come up where I’ve wished for this feature to make coding much simpler.