user3415509
user3415509

Reputation: 17

IntelliSense: "count" is ambigous

#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

Upvotes: 1

Views: 85

Answers (1)

Ilya
Ilya

Reputation: 114

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"

Upvotes: 2

Related Questions