473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

"using"

Is it legal to do this:

using std::out, std::cin, std::endl;

If not, why not?

--
http://www.munted.org.uk

"Honestly, what can I possibly say to get you into my bed?" - Anon.
Mar 3 '06 #1
6 1560
Alex Buell wrote:
Is it legal to do this:

using std::out, std::cin, std::endl;
No.
If not, why not?


Because the Standard says so. If you need rationale behind that
particular part of the Standard, ask in comp.std.c++.

V
--
Please remove capital As from my address when replying by mail
Mar 3 '06 #2
* Alex Buell:
Is it legal to do this:

using std::out, std::cin, std::endl;
Does it compile?

If not, then you can be reasonably sure it's not "legal", in the sense
of valid standard C++.

But if it does compile, you'll have to check the standard, that is, Read
The [beep] Documentation.

If not, why not?


If not, then it's not part of the syntax of the language.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 3 '06 #3
On 2006-03-03, Alex Buell <al********@munted.org.uk> wrote:
Is it legal to do this:

using std::out, std::cin, std::endl;
It's probably legal; you should ask a lawyer. But it's an error in
C++. ;-)
If not, why not?


C++'s namespaces are not a module system. They are a lower-level
feature than that, providing the simplest possible tools to prevent
name-clashes in arbitrary code. Your proposal, while convenient, isn't
part of a complete and minimal interface.

Moreover, I'd want something even more convenient:

using (std) out, cin, endl;

--
Neil Cerutti
Mar 3 '06 #4
"Alex Buell" writes:
Is it legal to do this:

using std::out, std::cin, std::endl;


No, and it's a pain. If you are freaked out about using namespace std, the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.
Mar 3 '06 #5
On Fri, 3 Mar 2006 10:02:51 -0800, "osmium" <r1********@comcast.net>
wrote:
"Alex Buell" writes:
Is it legal to do this:

using std::out, std::cin, std::endl;
No, and it's a pain. If you are freaked out about using namespace std,


Why should you? You can write 'using namespace xyz' in all *.cpp files
and explicitly qualify in the rare case of a name clash.
the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.


.... or just 'using namespace xyz'

Best wishes,
Roland Pibinger
Mar 3 '06 #6
On Fri, 3 Mar 2006 10:02:51 -0800 "osmium" <r1********@comcast.net>
waved a wand and this message magically appeared:
using std::out, std::cin, std::endl;


No, and it's a pain. If you are freaked out about using namespace std, the
best workaround I know of is to put a bunch of the ones you use in a header
file, keep it handy, and add the header when needed. I would make it the
last header file included.


I'm not in the least bit freaked out using namespaces, it's just
irritating sometimes to have to pull in just the ones you want to use
if you can't use 'using namespace std' instead.

--
http://www.munted.org.uk

"Honestly, what can I possibly say to get you into my bed?" - Anon.
Mar 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Justin | last post by:
Hi. I decided to tidy up some of my queries, but I came across something that stumpt me: mysql> SELECT -> jobs.jobId, -> jobs.active, -> jobs.title, -> jobs.listed, -> ...
2
by: Petr Jakes | last post by:
Hi, I am trying to set-up communication to the coin change-giver from my Linux box using the Python code. The change giver uses MDB (Multi Drop Bus) serial protocol to communicate with the...
0
by: Oliver | last post by:
> I am seeing an 'Access Denied' exception when using a "Server" "Serviced Component" >> ..are...registered in the GAC ? yes. >> ..are...the parameters serializable? um - parameters? - the...
7
by: Willem van Rumpt | last post by:
Hi all, coming from an unmanaged programming background, I took my time to sort out the IDisposable and finalizer patterns. Just when I thought I had it all conceptually neatly arranged, the...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement is wrapped in try/catch error handling statement....
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
0
by: Rave | last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
15
by: arnuld | last post by:
-------- PROGRAMME ----------- /* Stroustrup, 5.6 Structures STATEMENT: this programmes *tries* to do do this in 3 parts: 1.) it creates a "struct", named "jd", of type "address". 2. it...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.