public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Pure virtual member and namespaces.
@ 1998-03-21 10:36 Savas Parastatidis
  1998-03-24  0:03 ` Martin von Loewis
  0 siblings, 1 reply; 2+ messages in thread
From: Savas Parastatidis @ 1998-03-21 10:36 UTC (permalink / raw)
  To: egcs

Dear all,

I think there is a problem while compiling the following example using the
latest snapshot of egcs:

#include <iostream>

using namespace std;

namespace FooNamespace
{
   class Foo
   {
   public:
      Foo() {}
      virtual void f() = NULL;
   };
}

class MyClass : public FooNamespace::Foo
{
public:
   MyClass() {};
   void f() { cout << "Boom" << endl; }
};

void main()
{
   MyClass* x = new MyClass;
   FooNamespace::Foo* foo = x;

   foo->f();
}

The message I get is:
/tmp/cca11232.s: Assembler messages:
/tmp/cca11232.s:257: Fatal error: Symbol __tfQ212FooNamespace3Foo already
defined.


Any ideas? Am I doing something wrong? Ah, the problem I talked about in a
previous message persists. I do not send this to comp.std.c++ as it is my
understanding that the following example complies with the standard. Please,
comment...

#include <map>

namespace X
{
   class foo1
   {
   public:
      int bar;
      friend bool operator<(const foo1&, const foo1&);
   };
}

bool operator<(const X::foo1& rhs, const X::foo1& lhs)
{
  cout << "using this" << endl;
  return (rhs.bar < lhs.bar);
}

namespace X
{
   class foo2
   {
   public:
      foo2()
      {
         MyMap m;
         foo1  f1, f2;
         m.insert(MyMap::value_type(f1, 1));
         m.insert(MyMap::value_type(f2, 1));
      }

   private:
      typedef std::map<foo1, int> MyMap;
   };
}

int main()
{
   X::foo2 f2;
}

Thank you very much,
--
Savas Parastatidis, PhD. Student, Claremont Bridge 353
Dept. of Computing Science, University of Newcastle, NE1 7RU, UK
e-mail: Savas.Parastatidis@ncl.ac.uk, tel. +44 191 222 8789
URL: http://www.ncl.ac.uk/~n5831124 , fax +44 191 222 8232


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-03-24  0:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-21 10:36 Pure virtual member and namespaces Savas Parastatidis
1998-03-24  0:03 ` Martin von Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).