13.07.2015 Views

BABAR C++ Course Running the Examples - HEPHY

BABAR C++ Course Running the Examples - HEPHY

BABAR C++ Course Running the Examples - HEPHY

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Inline FunctionsSummarySometimes, <strong>the</strong> time to execute a function is smallcompared to time to call itUse inline keywordinline double sqr(double x) {return x * x;}• any decent compiler will generate inline code insteadof function call if function is small• but inline keyword is only a hint to <strong>the</strong> compiler• inline functions are usually defined in header fileNow we covered enough C/<strong>C++</strong> so that every thingyou can do in Fortran you can now do in C/<strong>C++</strong>You can also do more than you can do in FortranNext session we introduce classes and start on <strong>the</strong>road towards object-oriented programming.• convention puts inline functions in file with .iccsuffix that is included by header fileConsequences of inline functions• program might be faster• program will be larger• might have poor instruction cache performance anddebugging might be harder<strong>BABAR</strong> <strong>C++</strong> <strong>Course</strong> 64 Paul F. Kunz<strong>BABAR</strong> <strong>C++</strong> <strong>Course</strong> 65 Paul F. Kunz

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!