www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/25/12:31:07

Date: Mon, 25 Oct 1999 14:22:53 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199910251222.OAA05221@acp3bf.physik.rwth-aachen.de>
To: djgpp AT delorie DOT com
Subject: Re: Linking problem
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B
X-Newsreader: TIN [version 1.2 PL2]
Reply-To: djgpp AT delorie DOT com

In article <3812BDDA DOT E709C2E1 AT hjc DOT edu DOT sg> you wrote:

>     I defined two classes call "cPoint" and "cRect" in a header
> file(crect.h). I also implemented them in the same file because I wanted
> to utilise the function inlining... 

You didn't "utilise the inlining" correctly, and that's exactly your
problem.

[...]
> class TInline {
> public:
>   TInline();
> ~TInline();
> };

> TInline::TInline() { /* empty */ }
> TInline::~TInline() { /* empty */ }

These two method implementations are *not* inlined. For that, you ought
to have put them *into* the class definition, like this:

class TInline {
public:
 TInline() { /* empty */ };
 ~TInline() { /* empty */ };
};

The rule of thumb is that you shouldn't generally have standalone
method implementations in a header file. Only inline methods
(implementation inside the class declaration) should be in there.

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019