[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++: Problem with overloading a constructor when splitting a
- To: nobody(at-nospam)cs.Technion.AC.IL
- Subject: Re: C++: Problem with overloading a constructor when splitting a
- From: Dan Kenigsberg <danken(at-nospam)cs.Technion.AC.IL>
- Date: Sun, 18 Nov 2001 12:47:20 +0200 (IST)
- Cc: linux-il(at-nospam)linux.org.il
- Delivered-To: linux.org.il-linux-il@linux.org.il
- In-Reply-To: <Pine.GSU.4.30_heb2.09.0111180211330.22738-100000@actcom.co.il> from "guy keren" at Nov 18, 2001 02:12:57 AM
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
>
>
> On Sun, 18 Nov 2001, Shaul Karl wrote:
>
> > > you have put an inline function inside a '.cc' file. since it is inline,
> > > it will NOT be included in the object file 'base.cc', and thus, during
> > > link, there base constructor will be undefined. this is your bug - not
> > > g++'s.
> > >
> > > fixes:
> > >
> > > 1. move the inline function into the header file.
> > > 2. make the function not 'inline'.
> >
> > Are there no other options? In particular, one that is both inline and
> > with split files? (inline for speed and splitting the src for
> > readability)
>
> by definition - no. you split source - you can't do inline. inline works
> if you put it in the header file. that's the idea of inline - copying the
> code to all other sources, rather then having a real function in the
> resulting object file.
>
This may seem an ugly feature of C++, but in fact it is better than the C
counterpart - macros. In fact, writing the implementation of inline functions
in header file is a beautiful gem, comparing to writing the implemetation of
calss templates in header files. Yuck.
Dan.
=================================================================
To unsubscribe, send mail to linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il