[EMAIL PROTECTED] wrote: > I have the piece of code below, and when i try compiling with the line > > g++ 753075304.cpp > > I get the following error message: > > 753075304.cpp: In function 'int main()': > 753075304.cpp:29: error: 'plus' was not declared in this scope > > I've gone over the code several times line by lin, and my eyes are > starting to bleed. It looks totally fine to me, and I'm actually > wondering whether I found a compiler bug, but more likely some weird > feature, or I'm just totally missing something. And before anyone asks, > yes it is homework, but I am trying to grade it, not do it. my version > of GCC (as reported by its man page) is 4.0.1 2005-07-11 and I am > running debian testing, kernel version 2.6.8-1-386 #1 > [snip program]
I get the following error using g++. I guess its self explanatory: rt.cc: In function `int main()': rt.cc:27: use of `plus' is ambiguous rt.cc:5: first declared as `double plus(double, double, double)' here /usr/include/c++/3.2.2/bits/stl_function.h:128: also declared as ` template<class _Tp> struct std::plus' here rt.cc:27: use of `plus' is ambiguous rt.cc:5: first declared as `double plus(double, double, double)' here /usr/include/c++/3.2.2/bits/stl_function.h:128: also declared as ` template<class _Tp> struct std::plus' here There is a plus function in stl_function.h and one in your code. So, the compiler cannot determine which function needs to be called. Now thats the problem with using namespace std. If you remove the 'using namespace std' and explicitly add std to calls to cout and cin, then your program would compile properly. I guess there's a point in C++ FAQs which focuses on why usage of namespace may cause a compile time error. _______________________________________________ Help-gplusplus mailing list Help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus