The g++ compiler complains with this error when I declare a friend thusly:
friend MyClass;
instead of
friend class MyClass;
Why should the class keyword be required? (the Borland C++ compiler, BTW, does not require it.)
Couldn't the compiler simply look-up MyClass in the symbol table and tell it was declared as a class? (it is obviously doing the look-up anyway because it complains when MyClass it not declared)
It is not like it is making a forward declaration of the class: I still have to have either declared the class above or at least have forward declared it.
It would make sense to me (would be great actually) if
friend class MyClass;
makes a forward declaration if needed, otherwise it just seems like syntactic salt to me.
I have been merrily using friend statements without the class or struct keyword with no compiler complaints for almost 20 years. Is this something fairly new?