New User? Sign Up  |  Sign In  |  Help
ask.
answer.
discover.
     
Search for questions :
My Profile

Dodolz

Open Question Bookmark and Share

Some help about C++ why we use in program using nanamespace std;?

why we use in program using nanamespace std;
plz anybody explain in simple detail

Posted 40 days ago

    Report Abuse
   Find Intereseting  
   E-Mail to Friends  
   Bookmark  
   Subscribe to Answer Alert  
Answers (4)

SkyWalker
The true form of cout, cin and various other standard commands in C++ is
std::cout
std::cin

By having the
using namespace std
you can use
cin
cout

Have fun.

40 days ago

( 0 )
( 0 )
   Report Abuse


answergal
When you use simple functions such as cout, cin and all those similar functions, they are all stored in iostream under the namespace std. By writing using namespace std;, you can import the contents of the namespace std into the current file, without having to call them. Example: without using namespace std: std::cout << "hello";
with using namespace std::cout << "hello";
it just makes it easier and is not needed.

40 days ago

( 0 )
( 0 )
   Report Abuse


PartyintheUSA
if we write #include<iostream>
it means, we must have declare its functions that are we going to use in our program.
as std::cout, std::cin, std::endl etc.

and if we don't want to declare function like this, we use "using namespace std". This line declares the functions are given above.
But Most easy way is , write your preprocessing header file like this.
#include<iostream.h>
in this way, you do not need to write using namespace std and std::cout, std::cin, std::endl . you will be able to use all the functions of <iostream.h>

Hope you understand !

Just try it.

40 days ago

( 0 )
( 0 )
   Report Abuse


PartyintheUSA
Hi,

The functions like cout and endl are inside namespace std. To understand what that means, have a look at this simple example:

#include <iostream>

namespace temp{
void func();
}

void temp::func(){}

int main(){
// func(); // compile error
temp::func();
return 0;
}

In the above program, the function func() is defined inside a namespace called temp, so in order to call it, you need to do temp::func(). There is one more way to do it and that is by including the namespace in the global namespace area like this:

int main(){
using namespace temp;
func();
return 0;
}

This will also work fine.

Varun

40 days ago

( 0 )
( 0 )
   Report Abuse

Edit your answer. Click save, when done.
Question Title Some help about C++ why we use in program using nanamespace std;?
Your Answer
Character Count ( Max. - 5000 ) : 88
Email this question link to friends
You must enter email-address, if name is entered and vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -

 

About Us | Privacy Policy | Sitemap | Terms of Use

Copyright © www.metroadvice.com. All rights reserved.

http://www.wikio.com