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.

ThreeVectorUsing a class objectCLHEP’s ThreeVector class (simplified)class Hep3VectorF {public:Hep3VectorF();Hep3VectorF(float x, float y, float z);Hep3VectorF(const Hep3VectorF &v);float x();float y();float z();float phi();float cosTheta();float mag();// much more not shownprivate:float fx, fy, fz;};• this is <strong>the</strong> header file• keyword class starts <strong>the</strong> declaration which iscontained within <strong>the</strong> {}• sort of like <strong>the</strong> function prototypes• an object of a class contains data• an object of a class has certain functions associatedwith itConsider (clhep/threeVector0.C)#include #include int main() {float x, y, z;while ( cin >> x >> y >> z ) {Hep3VectorF aVec(x, y, z);cout

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

Saved successfully!

Ooh no, something went wrong!