title: Why am I getting this error: Not declared in this scope
body: <p>I have this C++ code that contains the following errors: <br>
  1. <code>readBinaryFile</code> was not declared in this scope<br>
  2. <code>ret</code> was not declared in this scope<br>
  3. <code>recursiveBinarySearch</code> was not declared in this scope. <br></p>
  
  <p>Can someone please help me understand why these errors are coming up?</p>
  
  <p>Thank you in advance.</p>
  
  <p>BinarySearch.h</p>
  
  <pre><code>    #ifndef BINARYSEARCH_H
      #define BINARYSEARCH_H
  
      using namespace std;
  
      class BinarySearch
      {
  
         public:
             char readBinaryFile(char *fileName);
             int recursiveBinarySearch(int start_index, int end_index, int        targetValue);
      };
  
      #endif
  </code></pre>
  
  <p>BinarySearch.cpp</p>
  
  <pre><code>    #include&lt;iostream&gt;
      #include&lt;fstream&gt;
      #include&lt;cstdlib&gt;
      #include&lt;vector&gt;
      using namespace std;
  
      //vector to dynamically store large number of values...
      vector&lt;unsigned int&gt; ret; 
  
      //variable to count the number of comparisions...  
      int n=0;  
      //method to read file....  
      void readBinaryFile(char* fileName)
      {
          ifstream read(fileName);
          unsigned int current;
          if(read!=NULL)
          while (read&gt;&gt;current) {
              ret.push_back(current);
          }
  
      }
  
      //recursive binary search method
  
      void recursiveBinarySearch(int start_index, int end_index, int targetValue)
      {
  
         int mid = (start_index+end_index)/2;
  
         if(start_index&gt;end_index)
         {
            cout&lt;&lt;n&lt;&lt;":-"&lt;&lt;endl;
             return ;  
         }
  
         if(ret.at(mid)==targetValue)
         {
            n++;
             cout&lt;&lt;n&lt;&lt;":"&lt;&lt;mid&lt;&lt;endl;
             return ;  
         }
         else if(ret.at(mid)&lt;targetValue)
         {
             n=n+2;//upto here two comparisions have been made..so adding two
             start_index=mid+1;
             return recursiveBinarySearch(start_index,end_index,targetValue) ;
         }
         else
         {
             n=n+2;
             end_index=mid-1;
             return recursiveBinarySearch(start_index,end_index,targetValue) ;
         }
      }
  </code></pre>
  
  <p>BinarySearch_test.cpp</p>
  
  <pre><code>    #include "BinarySearch.h"
      #include &lt;iostream&gt;
      #include &lt;fstream&gt;
      using namespace std;
  
      int main()
      {
  
         char a[] ="dataarray.bin";
         //assuming that all integers in file are already in sorted order
         readBinaryFile(a);
  
         int targetValue;
         cout&lt;&lt;"Enter a Value to search:";
         cin&gt;&gt;targetValue;
  
         recursiveBinarySearch(0,ret.size()-1,targetValue) ;
  
  
         return 0;
  
      }
  </code></pre>