Jump to content
  • Advertisement
Sign in to follow this  
derekpainter1

cout error in this small program

This topic is 4545 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!