Cout Was Not Declared In This Scope Dev C

Hi guys,
I have a code in C++ that was written way back in 1995.Back then,I guess even in C++,#include<iostream.h> was used unlike nowadays, #include<iostream> using namespace std;.....im rite now trying to compile that code with a g++ compiler.It gives the error at lots of places:'cout not declared in this scope'....I have tried using namespace std.....but if I use that then errors sprout up in files that belong to C++ standard library.....so I haven't been able to use using namespace std;.......i have even tried using std::cout<<......<<std::endl.....but even that is not working..........any ideas to get past this problem are appreciated.

'endl' was not declared in this scope. C / C Forums on Bytes. You need to show how this relates to the place where you declared x. Maybe post the complete code - or at least show enough to be able to reproduce the problem. Error: `cout' was not declared in this scope error: `endl' was not declared in this scope error: `cin' was not declared in this scope Could please youtell me how can I do,thank you. Wenli wang th26,August,2010.

Dev

Thanks........

  • 4 Contributors
  • forum 10 Replies
  • 7,064 Views
  • 1 Day Discussion Span
  • commentLatest Postby KAY111Latest Post

Ancient Dragon5,243

post one of the files that has the errors, especially the top of the *.cpp file where you have all the includes etc. The problem is most likely missing something like this:

Dev

Cout Was Not Declared In This Scope In Dev C++

or this

or like this:

Dev C++ Error Cout Was Not Declared In This Scope

Edited by Ancient Dragon: n/a

Dev C++ Cout Was Not Declared In This Scope

Namespaces separate and organize functionality. You can have a 'xander333::sort()' function and it won't conflict with 'std::sort()' or 'boost::sort()' or any other sort(). Without namespaces their can be only one sort().
Now let's say you've put 'using namespace std;' in all your source files and you've implemented a simple templated function called 'fill()' in the global namespace of one of your files. This file also depends on a header from libFoo -- 'foo.hpp'. Version 2.1 of libFoo comes out and all of a sudden your program no longer compiles. You version of 'fill()' suddenly conflicts with another 'fill()'! What happened???
It turns out that the folks implementing libFoo included <algorithm> in the new version of 'foo.hpp' when they didn't before. Now you have all of the standard algorithms being included in your source file, and your 'using namespace std;' has pulled them all into the global namespace. std::fill() now directly conflicts with your fill().
More insidious, you've gotten your code to compile by renaming your fill() to xander333_fill(), but something's not working right -- your report numbers are off. It turns out that your custom divides() function, which does fixed precision math, is no longer being called because the templated function from <functional> (also newly included by 'foo.hpp') makes for a better match because you're calling types did not exactly match the declared types.