title: pass class variable to exception in C++
body: <p>This is a (modified) problem from a test last week.
  I was given an exception class with a predefined number in it:</p>
  
  <pre><code>class ErrorException  {
  
      /**
      * Stub class.
      */
  private :static long ErrorCode;
  
  public: ErrorException( string str) {
                  cout &lt;&lt;str;
          }
  };
  
  long ErrorException::ErrorCode = -444;
  </code></pre>
  
  <p>I think I was supposed to do was catch the exception and then return the number as an error code, but I could not figure out how to get the number in. I could make the catch return a string but not the number as string: </p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include "ErrorException.h"
  
  #include "errno.h""
  #include &lt;string&gt;;
  class FillerFunction {
  
  
  public :
  
          virtual int getFillerFunction(int x) throw (ErrorException) = 0;
  
  } // this notation means getFillerFunction is always throwing ErrorException?
  
  double calculateNumber(int y){
  //.....
  try{
       if (y !=0){
        throw(ErrorException(?????))
        }
  };
  
  double catchError(){
        catch(ErrorException&amp; x);
  };
  </code></pre>
  
  <p>I eventually made it return the string "error" which is no better than using an if statement. I've looked up other catch-throw examples in c++ and dynamic exceptions, but I can't find an example with an exception grabbing a variable defined in the class.How do I access the ErrorCode, save changing the return type of ErrorException()?</p>