www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/05/18:19:18

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bad debugging code for class functions in header
Date: Sun, 05 Oct 1997 13:52:10 -0700
Organization: Alcyone Systems
Lines: 32
Message-ID: <3437FDFA.F827D41@alcyone.com>
References: <3 DOT 0 DOT 3 DOT 32 DOT 19971004082139 DOT 0069c228 AT utw DOT com>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Kurt Wall wrote:

> >If I have a header file like:
> >
> >class foo
> >{
> >public:
> >  void fred()
> >  {
> >    for (int i = 1; i < 1000; i++)
> >       bill(i);
> >  }
> >  void bill() {}
> >};
> Tsk, tsk.  Putting code in a header file...

In C++ this is a common practice, because it is one way of getting
member functions to be inlined.  (This particular examine is bad, since
foo::fred contains a loop and thus would not be suitable for inlining in
the first place; but foo:bill would be.)

I prefer to spearate inline member function off in an .icc file, but
defining them in the class declaration itself is perfectly legal draft
standard C++.

-- 
          Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                        Alcyone Systems / http://www.alcyone.com/max/
   San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                      \
   "After each war there is a little / less democracy to save."
                                    / Brooks Atkinson

- Raw text -


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