LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2003, 10:25 AM   #1
xaoc
LQ Newbie
 
Registered: Feb 2003
Posts: 3

Rep: Reputation: 0
C++ using namsespace std


Hi there,

I was wondering what does "using namespace std" after the #include statements do?
Our teacher just told us to use it.. but it also works and I have seen codes without it?
 
Old 02-18-2003, 02:47 PM   #2
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
std contains all the names defined in the namespace collection. So typing 'using namespace std' makes all of the collection public which some C++ programmers don't like to do, they would rather make only specific namespaces available (only the ones that they require).
 
Old 02-18-2003, 06:54 PM   #3
FreakboY
Member
 
Registered: Jun 2002
Location: TX, USA
Distribution: Slackware
Posts: 385

Rep: Reputation: 32
well...

when u don't specify "using namespace std"
and u try to use the cin & cout functions they
won't work unless u add the ".h" to ur #includes
so keep an eye on that...
if i don't make my self clear please... speak up!

laterz...
 
Old 02-18-2003, 07:14 PM   #4
GtkUser
Member
 
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637

Rep: Reputation: 30
Code:
#include<iostream>

using std::cout;
using std::endl;

int main()
{
  cout << "Hello World." << endl;
  return 0;
}
 
Old 02-18-2003, 07:28 PM   #5
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
This thread would be helpful.

http://www.linuxquestions.org/questi...threadid=43963
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what does the std:: do? RHLinuxGUY Programming 1 11-15-2005 01:01 PM
Std C++ Thaith Programming 7 08-28-2005 05:45 AM
P.H.L.A.K. or Knoppix STD fatrandy13 Linux - General 3 10-21-2004 10:28 AM
Knoppix Std OMEGA-DOOM Linux - Distributions 2 06-28-2004 02:37 PM
knoppix std!! viral Linux - Software 1 11-30-2003 06:49 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration