It's my esteemed privilege to try and repair some old legacy code (or at least gather enough evidence to convince the powers at be to let my team rewrite it)...in digging through this code (which is devoid of comments) I've come across something that seems a bit weird. Here's a paraphrasing of the declaration:
[source]
class foo
{
public:
class event;
private:
class request
{
friend class event;
public:
doStuff();
private:
LOTS OF INTERNAL METHODS
}
class response
{
friend class event;
public:
doStuff();
private:
LOTS OF INTERNAL METHODS
}
}
[/source]
Now, I've seen nested class definitions before, and I've seen the friend keyword in use before, but I've never seen the friend keyword used like this. There are several other classes with this very structure, unspecified class 'event' friended to 'response' and 'request' and others. Is the goal to instantiate foo1, foo2, etc. then iterate over unspecified object pointers, controlling them through this 'event interface'?
Maybe it's a design paradigm one of you has seen in the past (and not just something this programmer made up) so I thought I'd ask. What could be gained from this? (Other than some obfuscation, which isn't out of the question.) Naturally it's hard (maybe impossible) to determine what the point is without the code base (which I can't share directly). However, these classes aren't instantiated in the code I have because it's a library, and while I technically know what the library accomplishes, I'm now at a loss as to how I might wield it.
Oh, I found a comment. It says "// TODO: FIX". It's the only one. I lol'd.
So, possibly you've seen this or have a sharper imagination than I. In any case, thanks in advance for your time. :)