If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
using namespace std;
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
I'm wondering if it isn't better to only declare what someone wants to
use such as:
using std::vector;
using std::cout;
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope? 4 1578 tr*********@verizon.net wrote:
If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
using namespace std;
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
I'm wondering if it isn't better to only declare what someone wants to
use such as:
using std::vector;
using std::cout;
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope?
If "using namespace /X/" is contained within an individual translation
unit (a .cpp file) then it is a rather local "pollution" that can be
easily changed (assuming you aren't writing .cpp files that are
thousands of lines long.)
However putting using declarations or definitions in header files have a
much wider effect. tr*********@verizon.net wrote:
If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
using namespace std;
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
I'm wondering if it isn't better to only declare what someone wants to
use such as:
using std::vector;
using std::cout;
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope?
I believe there is a FAQ on that. See 27.5.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Oct 28, 9:23 am, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
tron.tho...@verizon.net wrote:
If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
using namespace std;
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
I'm wondering if it isn't better to only declare what someone wants to
use such as:
using std::vector;
using std::cout;
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope?
I believe there is a FAQ on that. See 27.5.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Where can the FAQ be found?
On 2007-11-02 02:49, tr*********@verizon.net wrote:
On Oct 28, 9:23 am, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>tron.tho...@verizon.net wrote:
If I remember correctly, in one of his books, Scott Meyers suggests
putting code into a custom namespace rather, and here I might be
paraphrasing, "polluting the global namespace" with type definitions
and such.
Assuming this is a good idea, I'm wondering about what happens when so
many people do the following:
using namespace std;
It seems like such a statement will bring a lot of stuff into the
global namespace, and a lot of it won't be used at all. Most people
only make use of a small portion what contained in the std namespace.
I'm wondering if it isn't better to only declare what someone wants to
use such as:
using std::vector;
using std::cout;
What kind of difference can it make to use either approach for
promoting items for a specific namespace for use in global scope?
I believe there is a FAQ on that. See 27.5.
Please do not quote signatures.
Where can the FAQ be found?
Normally it can be found at http://www.parashift.com/c++-faq-lite/
though here have been some DNS problems so if that does not work try http://www.coders2020.com/cplusplus-...ned/index.html
--
Erik Wikström This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brandon J. Van Every |
last post by:
I'm realizing I didn't frame my question well.
What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
up in your chair and scream "Wow! Ruby has *that*? That is SO...
|
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: Pekka Niiranen |
last post by:
Hi there,
I have two scripts. The first "main.py" sets some variables
and then imports another called "gen.py". The idea is to
provide "main.py" that defines some paths, variables etc.
without...
|
by: EMonaco |
last post by:
All,
I have a simple C# window app under MyApp namespace it has a class Form1.
I've added another class .cs file.
Now this class I want to share with many projects, so I figured I'd change
this...
|
by: clintonG |
last post by:
When using Visual Studio.NET I observe adding a new Web Form may have
default References added such as...
References
o- System
o- System.Data
o- System.Drawing
o- System.Web
o- System.XML
|
by: xzzy |
last post by:
I was wondering why we have to have
using System.Data
using System.Configuration
using etc....
why are they not all lumped into one 'using'?
In other words, is there a best way to use...
|
by: Arjang |
last post by:
http://www.codeproject.com/useritems/CSharpVersusVB.asp
|
by: Peter Kirk |
last post by:
Hi,
there is a logging service called "log4net". It uses namespaces such as
"log4net" and "log4net.Appender".
If I am writing my own software, would it be considered bad style to use...
|
by: TT (Tom Tempelaere) |
last post by:
Hi all,
I created an XSD to define the structure of an XML file for my project. I
made an XML file linked to the XSD using XmlSpy. The problem is that if I
read the file using .NET XmlDocument...
|
by: Juha Nieminen |
last post by:
Whenever one sees example C++ code basically anywhere, be it
in a book, in a tutorial in the internet, in an online forum
or whatever, I would estimate that at least in 99% of cases one
sees the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |