Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Bo Persson" Newsgroups: comp.lang.c++ Subject: Re: header only C++ code or not? Date: Thu, 7 Jul 2011 19:16:15 +0200 Lines: 21 Message-ID: <97m7unFppkU1@mid.individual.net> References: <16efe2a8-09b1-4d1d-9550-f6330de89718@j15g2000yqf.googlegroups.com> <20110707142407.4e2f0d3c@arcadia> X-Trace: individual.net Y51/NJYvwpmLDiLYRjSPJAZf/u3qUZ0bU8qACbdAQwkVCEiX+x Cancel-Lock: sha1:AG4UeLHuAw+9TSHTnj8jnK9FXoM= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Original X-Antivirus: avast! (VPS 110707-0, 2011-07-07), Outbound message X-Antivirus-Status: Clean Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:7594 Thomas Boell wrote: > On Wed, 6 Jul 2011 14:27:43 -0700 (PDT) > kathy 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. Recent versions of most C++ compilers can do that. Bo Persson