title: Visual Studio Gives Ambiguous Error for No Real Reason
body: <p>It gives the following error:</p>
  
  <p><code>error C2872: 'count' : ambiguous symbol</code></p>
  
  <p>Count variable has been declared as a global variable and the code compiles and runs in Sublime Text. Don't understand why Visual Studio is crying over it.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  using namespace std;
  
  int** am; // Adjacency matrix
  int* ar, * ar2; // Arrays to work with
  int n; // Number of nodes
  int node1, node2, k; // For reading input from the console
  int count;
  
  bool checkReachability(int, int, int);
  void fillArray(int);
  void updateArray(int,int);
  void freeMemory();
  
  int main() {
  
      ifstream in;
      in.open("Input2.txt");
      int a, b;
      if(in.is_open()) {
          in &gt;&gt; n;
  
          // Allocate memory on the heap dynamically for the adjacency matrix:
          am = new int*[n];
          ar = new int[n];
          ar2 = new int[n];
          for (int i = 0; i &lt; n; i++) {
              am[i] = new int[n];
          }
  
          // Initialize the values of the adjacency matrix with 0s and the principle diagonal with 1s initially:
          for (int i = 0; i &lt; n; i++) {
              for (int j = 0; j &lt; n; j++) {
                  if (i == j) {
                      am[i][j] = 1;
                  } else {
                      am[i][j] = 0;
                  }
              }
          }
  
          while(!in.eof()) {
              in &gt;&gt; a &gt;&gt; b;
              am[a-1][b-1] = 1;
          }
  
          cout &lt;&lt; "The adjacency matrix input is as follows: \n\n";
          for (int i = 0; i &lt; n; i++) {
              for (int j = 0; j &lt; n; j++) {
                  cout &lt;&lt; am[i][j] &lt;&lt; "  ";   
              }
              cout &lt;&lt; endl &lt;&lt; endl;
          }
          in.close();
      } else {
          cout &lt;&lt; "\nError reading the input file\n\n";
      }
  
  
      char c;
      do {
          cout &lt;&lt; "\nPlease enter the input (node1, node2, k): \n";
          cin &gt;&gt; node1 &gt;&gt; node2 &gt;&gt; k;
          fillArray(node1-1);
          count = 0;
          if(checkReachability(node1-1,node2-1,k)) {
              cout &lt;&lt; "\nReachable within " &lt;&lt; k &lt;&lt;  " steps";
              if (count &lt; k) {
                  cout &lt;&lt; " (actually " &lt;&lt; count &lt;&lt; ")";
              }
              cout &lt;&lt; endl &lt;&lt; endl;
          } else {
              cout &lt;&lt; "\nNot reachable within " &lt;&lt; k &lt;&lt; " steps  \n";
          }
          cout &lt;&lt; "\nDo you want to continue? Y/N \n\n";
          cin &gt;&gt; c;
      } while (c == 'Y' || c == 'y');
      freeMemory();
      system("pause");
      return 0;
  }
  
  
  bool checkReachability(int n1, int n2, int k) {
      if (n1 == n2) return true;
      count++;
      if (count &lt;= k) { 
          if (ar[n2] != 0) return true; 
          int x;
          for (int i = 0; i &lt; n; i++) {
              if (ar[i] != 0 &amp;&amp; i != n1) {
                  ar[i]++;
                  x = ar[i];
              }
          }
          for(int i = 0; i &lt; n; i++) {
              ar2[i] = ar[i];
          }
          for(int i = 0; i &lt; n; i++) {
              if (ar2[i] == x) {
                  fillArray(i);
                  updateArray(x,i);
                  if (checkReachability(ar2[i], n2, k)) return true;
              }
          }
      }
      return false;
  }
  
  
  void fillArray(int x) {
      // To fill the array with the adjacencies of a particular node
      for(int i = 0; i &lt; n; i++) {
          ar[i] = am[x][i];
      }
  }
  
  
  void updateArray(int x, int y) {
      for(int i = 0; i &lt; n; i++) {
          if (ar[i] == 1 &amp;&amp; i != y) {
              ar[i] = x;
          }
      }
  }
  
  
  void freeMemory() {
      // To free the dynamically allocated memory on the heap
      for (int i = 0; i &lt; n; i++) {
          delete [] am[i];
      }
      delete [] ar;
      delete [] ar2;
  }
  </code></pre>