Hi,
I am not sure if this is a relevant topic here, anyways,
When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a
better thing to do ? The confusion because different books suggest
different things ..
thanks in advance,
vivekian 6 2252
vivekian wrote: Hi,
I am not sure if this is a relevant topic here, anyways,
When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a better thing to do ? The confusion because different books suggest different things ..
The important consensus is to avoid "using namespace std;" in header files.
Best
Kai-Uwe Bux
> The important consensus is to avoid "using namespace std;" in header
files.
This would be true for any namespaces IMO.
On 2006-05-29 16:54, Kai-Uwe Bux wrote: vivekian wrote:
Hi,
I am not sure if this is a relevant topic here, anyways,
When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a better thing to do ? The confusion because different books suggest different things ..
The important consensus is to avoid "using namespace std;" in header files.
Something in between would be to use "using std::string;" which lets you
access string without having to prefix it with std:: without dragging
everything in std:: into your namespace.
Erik Wikström
--
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure
out how to use my telephone" -- Bjarne Stroustrup
"vivekian" writes: When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a better thing to do ? The confusion because different books suggest different things ..
I keep namespaces out of header files and prefix each translation unit with
using namespace std;. This does have the hazard that the language gurus
have used some word I want to use for an identifier and took first cut at
it. I have resigned myself to unintelligible error messages so that can be
pretty darn annoying to find when it happens. As long as you keep in mid
that this might be happening, I think you are OK. I will concede there
might be giant programs with fifty or so programmers, where this might be a
bad choice.
I have been tempted to make a new "kind" of header file with the using
declarations I, personally, typically use and am aware of. It would,
necessarily, be the last header file to be included.
"vivekian" <vi********@gma il.com> wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com... Hi,
I am not sure if this is a relevant topic here, anyways,
When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a better thing to do ? The confusion because different books suggest different things ..
thanks in advance, vivekian
I personally don't write "using namespace std;" in my code at all. I think
the five extra characters in each identifier are a small price to pay to
clarify where each symbol is coming from and to prevent name collisions.
Keep in mind std is a VERY big namespace and will grow with each major
update of the standard.
"vivekian" <vi********@gma il.com> wrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com... Hi,
I am not sure if this is a relevant topic here, anyways,
When using the std namespace is it a good practice to ..
put this right at the beginning
using namespace std ;
or is prefixing std before each feature access e.g. std::string a better thing to do ? The confusion because different books suggest different things ..
The FAQ answers this about using namespace std; http://www.parashift.com/c++-faq-lit....html#faq-27.5 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mikko Nummelin |
last post by:
As the XSLT namespace is declared to be used in XSL documents like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
, isn't this a risky practice as it refers to an external web site and if
that web site is down at a particular time or is moved to another place,
then even large web sites referring to it may fall down with it. So, is it
possible to obtain a local copy of such a namespace and refer to...
|
by: Koster |
last post by:
Something I've been puzzled over for a while. This really has no consequence at
all, but I'm curious for the _reason_ behind where we commonly place the
asterisk when declaring pointer variables.
When defining a variable which is of pointer-to-foo type, it seems the
'convention' is to put the asterisk before the variable's identifier, like this:
foo *ptr;
The C standards all seem to use this conventions, but it is equally valid
(AFAIK)...
|
by: Richard Brown |
last post by:
I think I might be on track to a misnomer that I keep running into.
A lot of the assemblies that I reference are named "System",
"System.Drawing", etc. There are dlls, ie, system.dll and
system.drawing.dll", etc. However, in my Imports statements, I also use
Import System and Import System.Drawing, which I assume are 'namespaces'.
So, is it that Microsoft just wanted to confuse us by naming them the same,
or is there some direct...
|
by: Phill. W |
last post by:
Having changed a VB.Net(2003) DLL project, I'm getting Type
Loading problems in other code that uses my DLL. In my source
code, I have a Namespace Statement something like this:
Namespace XYZ.AProject
but when I build the DLL project and open the resulting DLL up
in ILDASM, the Namespace has been *translated* to
"XYZ.Aproject".
|
by: **Developer** |
last post by:
I looked at MSDN and a book and both described the naming convention for
parameters should be camel style.
The book used camel, except for Set (ByVal Value as ...)
There it always used an uppercase V
What is the correct convention for Set?
| |
by: mrpubnight |
last post by:
Hi everyone, just hoping to get some opinions from those who have been
using/creating namespaces for a while.
Currently I have our namespace as follows:
CompanyName.Location.Client.Class
So for class DMRequest I may do something like this:
ABC.Base.DMRequestBase -base class
|
by: Jonathan Wood |
last post by:
I was just wondering what naming convention most of you use for class
variables.
Underscore, "m_" prefix, camel case, capitalized, etc?
Has one style emerged as the most popular?
Thanks for any comments.
--
|
by: Smithers |
last post by:
Is it common practise to begin the name of form classes with "frm" (e.g.,
frmOneForm, frmAnotherForm).
Or is that generally considered an outdated convention?
If not "frm" what is a common or recommended practise?
Thanks.
|
by: huohaodian |
last post by:
I have a webservice class MyService.asmx.cs with:
namespace XMLWS
{
public class Poster : System.Web.Services.WebService
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |