Hello, thanks for viewing my question.
I am teaching myself C++ from a book; the program below is supposed to show an example of local and global variables and how they are used.
As I was about to run and compile my program I ran into an error: "count" is ambiguous. I use the global variable more than once in the program so here is one example:
count = i* 2;
.
Now I have been researching on the internet about this compile error and some said its because of the following code
using namespace std;
and I know this tells the compiler to use all the std namespace, but I have tired to just remove that line of code and then the
cout
statements turn up an error; then I tired to use the code
std::cout
but I have no idea what they are used for, as my book just says use
using namespace std;
for now.
From what I found on the internet using Google the line of code
using namespace std;
has something to do with the count variable or something along the lines of that?
Here is the whole program:
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
|
#include <iostream>
using namespace std;
void func1();
void func2();
int count;
int main() {
int i;
for(i=0; i<10; i++) {
count = i* 2;
func1();
}
cout << "\n\n";
return 0;
}
void func1() {
cout << "Count: " << count;
cout << "\n";
func2();
}
void func2() {
int count;
for(count=0; count<3; count++) cout << ".";
}
|
Thanks if you answer and help me out!
Luke...