473,749 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 1566
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********@mun ted.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********@com cast.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********@com cast.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
1802
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, -> industries.industry, -> occupations.occupation,
2
12172
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 master. MDB protocol is the 9bit serial protocol: (TX, RX lines only) 9600bps, 9bits, No Parity, 1 Start, 1 Stop. I would like to control the UART "parity bit" to try to simulate 9bit communication.
0
1701
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 method parameters? - yes think so - there's only one and it's a 'string' here's an example class that illustrates the problem:
7
3012
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 "Close()" methods reared their ugly (at least it would seem...)heads. I was happily delving away in the .NET framework, investigating the stream classes with the msdn and Lutz Roeder's .NET reflector, when I stumbled upon the following:
5
8768
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. This works fine. When i try to implement the "SqlTransation" class, the code does not work as the SqlTransation object is out-of-scope in the catch statement, and/or, after the USING statement ends, the sql connection object is automatically...
14
3166
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 it makes difference to explicitly put them to null after working with them is done - it somehow makes the GC collect them sooner, like here: void SomeFunc() { MyClass c = new MyClass();
0
2797
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 Replace" fuction, I scan the merchandise which then searches the spreadsheet for the matching inventory number. When it is found, I highlight that cell in yellow. After scanning and coloring all of my inventory I can then see exactly what is...
21
7854
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
2678
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 then adds values to "jd" 3.) in the end it prints values of "jd".
25
2586
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 example: with quitCommandButton .enabled = true .default = true end with
0
8832
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,...
0
9386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
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 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...
0
8255
agi2029
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...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3319
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
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.