Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C and C++

Vote on your favorite hash algorithm here!

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-2006, 05:59 PM
Saint Saint is offline
Learning Programmer
 
Join Date: Aug 2006
Posts: 63
Credits: 0
Rep Power: 9
Saint is on a distinguished road
Default Count Undeclared?!?

I'm using g++ in Redhat linux and I have code like this:

Code:
#include <iostream>

int main()
{

cout << "Hello World!";
return 0;
}
but I get a count undeclared. Does iostream not have cout in it?
__________________
Hi >> Saint
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 10-01-2006, 01:27 AM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,253
Last Blog:
Passwords
Credits: 914
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John Send a message via MSN to John
Default

iostream does have cout in it lib, but you have to declare the namespace or whatever its called...try adding this below the header includes
Code:
using std::cout

Last edited by John; 10-01-2006 at 01:29 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-01-2006, 02:57 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,572
Last Blog:
wxWidgets is NOT code ...
Credits: 978
Rep Power: 29
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

Quote:
Originally Posted by Saint View Post
I'm using g++ in Redhat linux and I have code like this:

Code:
#include <iostream>

int main()
{

cout << "Hello World!";
return 0;
}
but I get a count undeclared. Does iostream not have cout in it?
Your error is probably "cout undeclared". cout is located in the std namespace, so your coude needs to either be
Code:
#include <iostream>

int main()
{

std::cout << "Hello World!";
return 0;
}
or

Code:
#include <iostream>

using std::cout;
int main()
{

cout << "Hello World!";
return 0;
}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-02-2006, 04:44 PM
dirkfirst dirkfirst is offline
Programming Professional
 
Join Date: May 2006
Posts: 338
Credits: 0
Rep Power: 11
dirkfirst is on a distinguished road
Default

I'm fairly sure he meant cout
__________________
DirkFirst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-03-2006, 07:32 PM
Saint Saint is offline
Learning Programmer
 
Join Date: Aug 2006
Posts: 63
Credits: 0
Rep Power: 9
Saint is on a distinguished road
Default

Whoops! I meant cout. When did linux start using Namespaces? I thought this was a microsoft thing. What is a namespace exactly, just another name for a class, right?
__________________
Hi >> Saint
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 10-05-2006, 11:33 AM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 2,572
Last Blog:
wxWidgets is NOT code ...
Credits: 978
Rep Power: 29
WingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the roughWingedPanther is a jewel in the rough
Default

Namespaces are a way to collect code from multiple files under an umbrella. For example, the standard library is in namespace std::. The advantage is that you are unlikely to accidentally use both the same namespace AND same variable/class name. But without namespaces you could easily use a somewhat obscure variable name and have a definition collision.

Namespaces are NOT part of linux, they are part of C++.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java:Tutorial - Tic-Tac-Toe John Java Tutorials 25 02-27-2008 06:41 PM
Othello program!! 24 hours left! siren C and C++ 1 06-14-2007 11:18 AM
Need help w/ word count program (ASAP) siren C and C++ 1 04-23-2007 08:14 AM
Getting Row Count Lop Managed C++ 2 01-10-2007 08:17 AM
How to Count number of button has been Click? roger Visual Basic Programming 4 06-01-2006 02:49 PM


All times are GMT -5. The time now is 07:23 PM.

Contest Stats

Xav ........ 1455.48
MeTh0Dz|Reb0rn ........ 1089.45
WingedPanther ........ 977.76
marwex89 ........ 962.9
John ........ 914.37
morefood2001 ........ 911.18
Brandon W ........ 823.79
chili5 ........ 312.39
Steve.L ........ 276.28
dcs ........ 253.49

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 84%

Ads