Re: [Dev-C++] use of `count' is ambiguous
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Markku P. <mar...@ko...> - 2004-08-19 20:54:38
|
It seems that 'count' is all ready defined inside template in stl_algo.h
E:/Dev-Cpp/include/c++/3.3.1/bits/stl_algo.h:390: error: also declared =
as `
typename std::iterator_traits<_Iterator>::difference_type
std::count(_InputIter, _InputIter, const _Tp&)' here
So... you can't use 'count' as global variable (rename 'count')
or
you can't use 'using namespace std;' (replace cout to std::cout)
-Mp
----- Original Message -----
From: "Scott Simontis" <age...@co...>
To: "Bob Tentinger" <rte...@am...>; "Dev-C++ User Group" <dev=
-cpp...@li...>
Sent: Thursday, August 19, 2004 2:49 PM
Subject: Re: [Dev-C++] use of `count' is ambiguous
> 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=92s
> > 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=3D0; i<10; i++) {
> >
> > count =3D 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=3D0; count<3; count++) cout << '.';
> >
> > }
> >
|