title: timer outside of a class
body: <p>I have the following code and I wanted to create a class that encapsulates the timer but the trouble I'm having is using the timer after declaring the class. I posted another block of code to show an example of how I want to use the timer. </p>
  
  <pre><code>double diffclock(clock_t clock1,clock_t clock2)
  {
      double diffticks=clock1-clock2;
      double diffms=(diffticks*1000)/CLOCKS_PER_SEC;
      return diffms;
  }
  void some_function()
  {   
      clock_t begin = clock();
  
      //do something
      clock_t end=clock();
      cout &lt;&lt; "Time elapsed: " &lt;&lt; double(diffclock(end,begin)) &lt;&lt; " ms"&lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>this is the header file</p>
  
  <pre><code>#ifndef SPECIALCLOCK_H
  #define SPECIALCLOCK_H
  #include &lt;ctime&gt;
  
  class specialclock
  {
      private:
  
      public:
  
      specialclock(){}
      ~specialclock(){}
      double diffclock(clock_t clock1,clock_t clock2);
  };
  double specialclock::diffclock(clock_t clock1,clock_t clock2)
  {
      double diffticks=clock1-clock2;
      double diffms=(diffticks*1000)/CLOCKS_PER_SEC;
      return diffms;
  }
  #endif
  </code></pre>
  
  <p>And this the the main file</p>
  
  <pre><code>#include "specialclock.h"
  
  int main()
  {
  
     specialclock timer;
  
  //how would I use the timer here?
  
     return 0;
  }
  </code></pre>