basic global var question

hi, i've been learning c++ for a very short time from Herbert Schilts book. i wrote the program from the book, but it won't compile. it can't be too hard, but i am completly new to the world of programming

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
using namespace std;

void f1();
void f2();

int count;

int main()
{
    int i;

    for(i=0;i<10;i++){
        count = i*2;//problem here
        f1();
    }

    return 0;
}

void f1()
{
    cout << "count" << count;
    cout << "\n";
    f2();
}

void f2()
{
    int count;

    for(count=0;count<3;count++) cout << ".";
}


i get a compile error(using code::blocks) that count is undeclared, in both f1() and f2(). i thought that the use of global variables (though not often) would prevent this error, as they can be assessed throughout the entire code.
what appears to be wrong? thanks for any simple help.
There is already something in the standard library called count.
Try calling the global variable by some other name.
thanks very much. i'll remember that
Topic archived. No new replies allowed.