Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7573

Re: header only C++ code or not?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder1.news.weretis.net!news.albasani.net!.POSTED!not-for-mail
From Thomas Boell <tboell@domain.invalid>
Newsgroups comp.lang.c++
Subject Re: header only C++ code or not?
Date Thu, 7 Jul 2011 14:24:07 +0200
Organization albasani.net
Lines 13
Message-ID <20110707142407.4e2f0d3c@arcadia> (permalink)
References <16efe2a8-09b1-4d1d-9550-f6330de89718@j15g2000yqf.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net vgg6ikeATi7mYZcVuBIQNZfH7bPKbpsLApehPu07zFSIQA5Fwhsq5LFCJfisV8mB3q/9l3RWN0v55D0Bt2XYjM8zHX0/SeFoIIWWm3IUikzhIBS4QDc1Or0irerJ77NO
NNTP-Posting-Date Thu, 7 Jul 2011 12:24:07 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="CI9GL4FaaU3C9uJrdxrDpy2rpr2KClEAWhUbQMa24t0SnTtSHIacTA5U+yJG6a9BZ7iWHeTD6XVYe+1nLCoW1CQdov6XyzI6TMQTg8EG6lUlQ3assv0tWzGcF2EGDnVr"; mail-complaints-to="abuse@albasani.net"
X-Newsreader Claws Mail 3.7.9 (GTK+ 2.24.4; i686-pc-linux-gnu)
Cancel-Lock sha1:sYKFWdfs89S95+eksZNx5xecrrA=
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:7573

Show key headers only | View raw


On Wed, 6 Jul 2011 14:27:43 -0700 (PDT)
kathy <yqin_99@yahoo.com> wrote:

> I have question about write C++ code. I have seen some developer use
> head only style (all class definition and implementation in .h file),
> But others like to seperate the definition and implementation in h /
> cpp file. Is this the style / favor only or there are some benefits to
> use one vs the other?

In addition to what others said, putting implementation in header files
can give the compiler better chances for optimization and inlining. If
the implementation is in a separate compilation unit, the compiler
can't inline because it doesn't know the function body.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

header only C++ code or not? kathy <yqin_99@yahoo.com> - 2011-07-06 14:27 -0700
  Re: header only C++ code or not? "Andrew Holme" <ah@nospam.com> - 2011-07-06 22:42 +0100
    Re: header only C++ code or not? "Bo Persson" <bop@gmb.dk> - 2011-07-07 19:17 +0200
  Re: header only C++ code or not? Sam <sam@email-scan.com> - 2011-07-06 17:23 -0500
  Re: header only C++ code or not? Noah Roberts <roberts.noah@gmail.com> - 2011-07-06 16:14 -0700
    Re: header only C++ code or not? "MikeP" <mp011011@some.org> - 2011-07-07 15:35 -0500
    Re: header only C++ code or not? "MikeP" <mp011011@some.org> - 2011-07-07 15:45 -0500
  Re: header only C++ code or not? "Paul" <pchristor@yahoo.co.uk> - 2011-07-07 01:24 +0100
  Re: header only C++ code or not? Thomas Boell <tboell@domain.invalid> - 2011-07-07 14:24 +0200
    Re: header only C++ code or not? "Balog Pal" <pasa@lib.hu> - 2011-07-07 14:57 +0200
      Re: header only C++ code or not? Garrett Hartshaw <ghartshaw@gmail.com> - 2011-07-07 11:40 -0400
        Re: header only C++ code or not? Thomas Boell <tboell@domain.invalid> - 2011-07-07 19:38 +0200
          Re: header only C++ code or not? Garrett Hartshaw <ghartshaw@gmail.com> - 2011-07-09 09:06 -0400
            Re: header only C++ code or not? Thomas Boell <tboell@domain.invalid> - 2011-07-09 16:23 +0200
    Re: header only C++ code or not? "Bo Persson" <bop@gmb.dk> - 2011-07-07 19:16 +0200

csiph-web