Jump to content
  • Advertisement
Sign in to follow this  
derekpainter1

cout error in this small program

This topic is 4466 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

could anyone please help me find the error here , compiler said "cout undeclared"

// ex 6 page 64

#include <iostream>

void DisplayTime(int,int);

int main()
{
  using namespace std;
  
  int hours;
  int minutes;
  cout<< " Please enter hours: "<<endl;
  cin >> hours;
  cout << " Please enter minutes: ";
  cin >> minutes;
  
 DisplayTime(hours,minutes);
  
  return 0;
}  
  
void DisplayTime(int h,int m)
{
cout << " Time: "<<h<<":"<<m;
}


Share this post


Link to post
Share on other sites
Advertisement
When you put using namespace std inside the main() function it only applies to the name lookups inside main(). If you want to apply it to the whole file you should place it before your function definitions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!