C++

Asked • 10/05/19

What is the difference between 'typedef' and 'using' in C++11?

I know that in C++11 we can now use `using` to write type alias, like `typedef`s: typedef int MyInt; Is, from what I understand, equivalent to: using MyInt = int; And that new syntax emerged from the effort to have a way to express "`template typedef`": template< class T > using MyType = AnotherType< T, MyAllocatorType >; But, with the first two non-template examples, are there any other subtle differences in the standard? For example, `typedef`s do aliasing in a "weak" way. That is it does not create a new type but only a new name (conversions are implicit between those names). Is it the same with `using` or does it generate a new type? Are there any differences?

1 Expert Answer

By:

David A. answered • 10/11/19

Tutor
4.7 (14)

Experienced C++ tutor who loves to mentor and pass on my knowledge

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.