357mag 3 Posted 8 hours ago Cool program which I like using a global variable. But the compiler says reference to count is ambiguous. It is one of Herb's programs, and I know his style of writing program is suspect, but his programs themselves as far as his ideas I have always liked. Here it is: #include<iostream> using namespace std; void functionOne(); void functionTwo(); int count; int main() { int i; for(i = 0; i < 10; i++) { count = i * 2; // reference to count is ambiguous functionOne(); } system("pause"); return 0; } void functionOne() { cout << "count: " << count; cout << endl; functionTwo(); } void functionTwo() { int count; for(count = 0; count < 3; count++) cout << '.'; } Share this post Link to post
Remy Lebeau 1461 Posted 8 hours ago (edited) Stay away from 'using namespace std;' !!! https://stackoverflow.com/questions/1452721/whats-the-problem-with-using-namespace-std Your count identifier is likely conflicting with std::count(). The compiler doesn't know which one you want. Consider using this instead: //using namespace std; using std::cout; using std::endl; using std::system; Or, put your count global variable in its own namespace. (Also, you are missing #include <cstdlib> for std::system()) Edited 7 hours ago by Remy Lebeau Share this post Link to post