c++ - std:: required when it should not be?
- Karim Naqvi <naqvik uregina.ca> Oct 18 2010
I have the following behaviour, which looks erroneous:
-------------file: problem.cpp-----------------
#include <cstdlib>
#include <new>
using namespace std;
void no_memory () {
exit (1);
}
int main () {
std::set_new_handler(no_memory);
return 0;
}
--------------------------
Here's the problem: if the std:: prefix on set_new_handler is removed we get a
compile error:
set_new_handler(no_memory);
^
problem.cpp(16) : Error: ambiguous reference to symbol
Had: set_new_handler(void (*C func)())
and: std::set_new_handler(void (*C func)())
--- errorlevel 1
If std:: is restored, it compiles and runs with no problem. It would seem
that the 'using namespace std' should obviate the need for the std prefix.
This is DMC v852.
Thanks for any clarification,
Karim Naqvi
Oct 18 2010








Karim Naqvi <naqvik uregina.ca>