Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

StatsApplication.cc

Go to the documentation of this file.
00001 #include "Statistics.hh"
00002 
00003 #include <unistd.h>
00004 #include <iostream.h>
00005 #include <string.h>
00006 #include <math.h> 
00007 #include <fstream.h>
00008 #include <complex.h>
00009 #include <stdlib.h>
00010 #include <stdio.h>
00011 #include <strstream>
00012 
00013 #include <string> 
00014    using namespace std;
00015 
00016 
00024 int main(void)
00025 {
00026 
00027   int NumberOfSamples;
00028 
00029   cout << "Enter number of samples: ";
00030   cin >> NumberOfSamples;
00031   cout << NumberOfSamples << endl;
00032 
00033   double * SampleArray;
00034 
00035   SampleArray = new double[NumberOfSamples];
00036 
00037   cout << "Enter the samples separated by spaces" << endl;
00038 
00039   for(int ii=0; ii < NumberOfSamples; ii++)
00040     cin >> SampleArray[ii];
00041 
00042   cout << "The samples are:" << endl;
00043 
00044   for(int ii=0; ii < NumberOfSamples; ii++)
00045      cout << SampleArray[ii] << " ";
00046  
00047   cout << endl;
00048 
00049 
00050   /* Construct an instance of the Statistics class which is called
00051      oStatistics. We call oStatistics a Statistics object. 
00052 
00053      You can think of Statistics as a user-defined type and oStatistics
00054      as a variable of that type. 
00055 
00056      To construct oStatistics we call the Statistics constructor
00057      which initializes all the data of the object oStatitics.
00058   */
00059 
00060 
00061 
00062   Statistics oStatistics(NumberOfSamples,SampleArray);
00063 
00064   /* To access the member function GetMinimim() of the object oStatistics we
00065      use the syntax  oStatistics.GetMinimum(). 
00066      In general we use MyClass.MyMethod().
00067   */
00068 
00069   cout << "Minimum = " << oStatistics.GetMinimum() << endl;
00070   cout << "Maximum = " << oStatistics.GetMaximum() << endl;
00071   cout << "Median = " << oStatistics.GetMedian() << endl;
00072   cout << "Mean = " << oStatistics.GetMean() << endl;
00073   cout << "Variance = " << oStatistics.GetVariance() << endl;
00074 
00075   cout << "THE END" << endl;
00076 
00077 
00078   return 1;
00079 
00080 } // ## end main
00081 
00082 // ###################################################
00083 
00084 /********
00085 
00086 // Sometimes people work with pointers to classes instead of working with the
00087 // classes directly. Here's how the syntax works:
00088 
00089   Statistics * oStatisticsPtr; // Pointer to a Statistics object 
00090 
00091   // oStatisticsPtr can point to the memory location of a Statistics object
00092 
00093   // Dynamically allocate memory for a  Statistics object using new
00094   // and let oStatisticsPtr point to the memory location of that object
00095  
00096    oStatisticsPtr =  new Statistics(NumberOfSamples,SampleArray);
00097 
00098   // Remember that oStatisticsPtr is a pointer to a Statistics object
00099   // It just stores the address of the Statistics object
00100   // The actual Statistics object is called *oStatisticsPtr
00101 
00102   // To access a member function of the object  *oStatisticsPtr use 
00103   // -> instead of ., as in oStatisticsPtr->MyFunction()
00104 
00105   cout << "Maximum = " << oStatisticsPtr->GetMaximum() << endl;
00106 
00107   // Alternatively, since the actual Statistics object 
00108   // is called *oStatisticsPtr you can access a member function 
00109   // you can also use:  (*oStatisticsPtr).MyFunction();
00110 
00111   cout << "Maximum = " << (*oStatisticsPtr).GetMaximum() << endl;
00112 
00113 ***********/
00114 
00115 
00116 

Generated at Fri Feb 21 10:29:46 2003 for hello by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000