1
#include "stdafx.h"
#include <iostream>

using namespace std;

void func(void);

static int count = 10; /* Global variable */

int main() {
   while(count--) {
      func();
   }
   return 0;
}

// Function definition
void func( void ) {
   static int i = 5; // local static variable
   i++;
   cout << "i is " << i ;
   cout << " and count is " << count << endl;
}

can't seem to fix this, just learning and reading Storage class in tutorialspoint.com . is this Visual Studio issue? because the code is working on Code::Blocks

Rakete1111
  • 47,013
  • 16
  • 123
  • 162

1 Answers1

3

There is a "count" function in std namespace, so it collides with you variable

You have several options: 1. Rename your variable to something else 2. Use "::count" instead of "count" (:: means global namespace and not std) 3. Don't do "using namespace std;", instead write "std::" in-front of everything that comes from std, for example: "std:cout", "std::endl"

Ilya
  • 125
  • 5