Topic: Nameless classes


Author: admin@rzaix13.uni-hamburg.de (Bernd Eggink)
Date: 27 Jul 1994 09:55:20 GMT
Raw View
Please look at this program:

 class Base
 {
   public:
  virtual void f() = 0;
 };

 class : public Base    // <====
 {
   public:
  void f() { cout << "f()\n"; }
 } x;

 int main(int argc, char *argv[])
 {
  x.f();

  return 0;
 }

If I want to have exactly one object per class, the ARM sais,
I can use a nameless class. Unfortunately the ARM sais nothing about
nameless derivated classes. I fed this program into BC4.0, and it worked.
But IBM's xlC gave me the error message

 (S) "Base" cannot be a base of "class {...}" because "Base" contains a
 member function called "class {...}".

which sounds somewhat confused. Now I'm confused, too. Which compiler is
right? Should an anonymous derivation from a base class be possible?

Thanks for any enlightenment.
--
+----------------------------------+
|          Bernd Eggink            |
|    Rechenzentrum Uni Hamburg     |
| admin@rzaix13.rrz.uni-hamburg.de |
+----------------------------------+