473,387 Members | 3,684 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,387 software developers and data experts.

What are the advantages ans disadvantages of employing the

What are the advantages ans disadvantages of employing the "using"
directive?
Jan 13 '18 #1
1 2285
weaknessforcats
9,208 Expert Mod 8TB
C++ requires that all names must be unique. To avoid name clashes you place names inside namespaces:

Expand|Select|Wrap|Line Numbers
  1. int x;
  2.  
  3. namespace system
  4. {
  5. struct data
  6. {
  7. int a,b,c;
  8. datat x;
  9. }
  10. namespace mystuff
  11. {
  12. double x;
  13. }
  14.  
These are three different variables with names of:

::x
system::x
mystuff::x

So far so good. Now let’s say you don’t like all this :: stuff in the variable name so you can tell the compiler to check a namespace for the variable name:

Expand|Select|Wrap|Line Numbers
  1. using namespace system;
  2.  
Now instead of coding system::x all you need is x because you have told the compiler you are using namespace system.


Expand|Select|Wrap|Line Numbers
  1. x= 10;
  2.  
However, this x might be ::x or system::x. If the x is ::x this code compiles. If the x is system::x, the code does not compile.

The using directive is for lazy programmers only. Top be safe you should always use fully qualified names in your
Jan 13 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jonathan | last post by:
Some one suggested me to alter my tables to InnoDB instead of myISAM type to improve speed for select queries. Is this really true. I read some article that stated that myISAM was optimized for...
14
by: Salad | last post by:
On the computer side of the businees there is me, the developer. Another person's role is that of the idea man...the person that knows the business and requirements and issues for the business. ...
3
by: Erik Lautier | last post by:
I have a content site where everything is currently in one SQL Server DB. As I add features to the site, for example message boards and blogging, does it make sense to put those features in a...
1
by: vibee | last post by:
what are the advantages and disadvantages of normalization, and if i alread have a single talbe with a single form, is it too late to normalize thanks
7
TRScheel
by: TRScheel | last post by:
I have seen this question appear many times in the forums, so I am writing this to hopefully help those who have this question. First, a history lesson! Your earlier languages compiled to assembly...
1
by: vijay pardhi | last post by:
what are the advantages & disadvantages of http? why http is a stateless protocol ? explain basic tags with example ?
1
by: Julie | last post by:
I just started this week on a new project. The existing project uses BEA Tuxedo as a second layer service broker. The clients make calls to the Tux services which in turn retrieves data from an...
2
by: Piotrekk | last post by:
Hi I have a question related to Socket class. What are the advantages / disadvantages of using Socket class comparing to TcpClient and HttpWebRequest Regards Piotr Ko³odziej
2
hsn
by: hsn | last post by:
hello i am currently studying this programming language it is an easy language so far. i am asking you guys do u think it is better than c++ and java or at least what advantages you see from...
4
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I am currently developing my first webapplication using .net (2.x) In a couple examples seen in the helpfile that came with VS2008 i see that they are opening a connection to the sql...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
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,...
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...

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.