Thursday, July 30, 2009

Can someone please check my C++ code?

i just downlaoded dev-C++ and i keeps asking me to declare cout. how do i do it in this particular program?





#include %26lt;iostream%26gt;


int main()


{


int x = 5;


int y = 7;


cout %26lt;%26lt; "\n";


cout %26lt;%26lt; x + y %26lt;%26lt; " " %26lt;%26lt; x * y;


cout %26lt;%26lt; "\n";


return 0;


}

Can someone please check my C++ code?
You need to put std:: before each cout, like this:





http://xoax.net/comp/cpp/console/Lesson2...





Or you can use a using directive to save yourself some typing:





http://xoax.net/comp/cpp/console/Lesson1...
Reply:It has to do with namespaces. You need to add the following line after the includes of your implementation (.cpp) files:





using namespace std;
Reply:you need to add "using std::cout;" after the #include


No comments:

Post a Comment