473,324 Members | 2,196 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,324 software developers and data experts.

Difference between `using` and `typedef`

Hi all,

Consider:

<>
namespace a {
namespace nested { class a_class {}; }
}
namespace b { using ::a::nested::a_class; }
namespace c { typedef ::a::nested::a_class a_class; }
</>

Is there any difference between b::a_class and c::a_class? I have a
feeling that b::a_class uses ADL, whereas c::a_class doesn't, but I'm
neither sure why [I think it] nor trust I have the right impression.

Are there any situations where there's a difference between the two?

Nov 3 '07 #1
1 1972
drrngrvy wrote:
Consider:

<>
namespace a {
namespace nested { class a_class {}; }
}
namespace b { using ::a::nested::a_class; }
namespace c { typedef ::a::nested::a_class a_class; }
</>

Is there any difference between b::a_class and c::a_class? I have a
feeling that b::a_class uses ADL, whereas c::a_class doesn't, but I'm
neither sure why [I think it] nor trust I have the right impression.

Are there any situations where there's a difference between the two?
You need to find the places where a typedef-name is unacceptable.
I can recall only a couple at this time: elaborate type specifiers,
definition of a constructor or destructor (a type name is needed).
Since it is unlikely you're going to define the c-tor or d-tor in
the other namespace, the only real "danger" is to use the name
'a_class' to declare it a friend of something in 'b' or 'c', which
requires an elaborate type specifier, where a typedef-name is not
allowed.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 3 '07 #2

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

Similar topics

2
by: Peter Steiner | last post by:
hi there! my problem: i need arrays of float-triples (math vector). i need these available in a flat float* array for batch processing (opengl). is an array of POD structs with three float...
6
by: nick | last post by:
I have tried finding an answer to this, but most people just explain classes as a more modular way to program. It seems to me that (forgetting OO programming which I don't quite understand) the...
14
by: code break | last post by:
what is the difference in this pointers decalarition ? int *ptr; and int (*ptr);
15
by: Daniel Rudy | last post by:
What is the difference between packed and unpacked structs? -- Daniel Rudy Email address has been base64 encoded to reduce spam Decode email address using b64decode or uudecode -m Why...
5
by: raghu | last post by:
can anyone please tell me difference between the two statements. #define ME int and typedef int ME Both statements do the same work.. right? Thanks a lot in advance.
6
by: fcvcnet | last post by:
Hi, I read the book C++ Primer, Fourth Edition By Stanley B. Lippman, Jos¨¦e Lajoie, Barbara E. Moo "If we define a class using the class keyword, then any members defined before the first...
7
by: ngpbalaji | last post by:
whats the Difference between Typedef and Define in C? we can Use both for the case below... #define INT32 int typedef int INT32; for both the case actually what will happen when compiling...
4
by: msukumarbabu | last post by:
Hi all, What will be difference between "typedef enum" and "enum". or difference between “typedef structure" and "structure" I am going through some code. in that some place they are using...
2
by: emitrax | last post by:
Hi there, is there any difference between using bit fields structure and plain variable plus macros for dealing with bits? Let's say I have a two bytes divided as follow 0 - 2: level 3 -...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.