Re: [Dev-C++] use of `count' is ambiguous
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Scott S. <age...@co...> - 2004-08-19 11:49:40
|
It's probably fussing that it has been declared twice, but I have no
idea how you can fix it. I reccomend just using different names rather
using global and local variations of a variable.
Bob Tentinger wrote:
> Line 14 C:\Developer\DEV-C++\C++ Dev\Program8.cpp use of `count' is
> ambiguous
>
> I am working through a beginners book on C++ and below is code that
> will not compile in DEV C++ 4.9 it gives me the error above. What’s
> wrong here?
>
> It will compile in Visual Studio 7.0.
>
> #include <iostream>
>
> using namespace std;
>
> void func1();
>
> void func2();
>
> int count; // this is a global variable
>
> int main()
>
> {
>
> int i; // this is a local variable
>
> for(i=0; i<10; i++) {
>
> count = i * 2;
>
> func1();
>
> }
>
> return 0;
>
> }
>
> void func1()
>
> {
>
> cout << "count: " << count; // access global count
>
> cout << '\n'; // output a newline
>
> func2();
>
> }
>
> void func2()
>
> {
>
> int count; // this is a local variable
>
> for(count=0; count<3; count++) cout << '.';
>
> }
>
|