SLAC PEP-II
BABAR
SLAC<->RAL
Babar logo
Workbook HEPIC Databases PDG HEP preprints
Organization Detector Computing Physics Documentation
Personnel Glossary Sitemap Search Hypernews
Unwrap page!
Wkbk. Search
Wkbk. Sitemap
Introduction
Non SLAC
HOWTO's
Introduction
Logging In
QuickTour
Detector
Info Resources
Software Infrastructure
CM2 Introduction
Unix
OO
SRT
Objectivity
Event Store
Framework
Beta
Modifying Code
Writing and Editing
Compiling
Debugging
Analysis
Framework II
Analysis
Find Data
Batch Processing
PAW
PAW II
ROOT I
ROOT II
ROOT III
Advanced Infrastructure
New Releases
Workdir
Main Packages
Event Displays
Gen/Sim/Reco
Contributing Software
SRT and CVS
Coding
Advanced Topics
Make CM2 Ntuples
New Packages
New Packages 2
Persistent Classes
Java
Site Installation
Check this page for HTML 4.01 Transitional compliance with the
W3C Validator
(More checks...)

Simple Class Declaration Example

//A canonical example of a class declaration and
//implementation is a complex number class.

//Here follows the class declaration.

class Complex { //begin declaration

public: //all public members follow

  Complex(double x, double y); //declaration of constructor
  ~Complex(); //declaration of destructor

  //put here accessor functions 

  double Re();
  double Im();
  double Mod();

  //put here operations

protected: //all protected members follow, perhaps none

private: //all private members follow, state data members 

  double _x; //real component
  double _y; //imaginary component

  //alternatively
  // double _r; //radius
  // double _theta; //argument
  //by making the state data members private the         
  //implementor is free to change between these two 
  //implementation of a complex number without affecting
  //the public member function declarations.

}; //end declaration with curly brace and semicolon

//The member function definitions might look something 
//like this:

Complex::Complex(double re, double im) { //begin definition of constructor
   _x=re;
   _y=im;
}

Complex::~Complex(){
  //does nothing
}

double Complex::Re(){
   return _x;
}

double Complex::Im(){
   return _y;
}

double Complex::Mod(){
  double z;
  z = sqrt(x*x + y*y); //sqrt in math library
}

etc.... 


Last edited by: Jenny Williams

Last modification: 11 Mar 2001
Last significant update: ?1999