What to C++ 11 features to cover in my C++ courses?

B

bobl0456

Hi folks,

I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.

To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:

array container
auto for type inference
delegating ctors
explicit conversion operators
final classes
final member functions
inheriting base class ctors
list initialization changes
move assignment operator
move ctor
non-deterministic random number generation
nullptr
override keyword
range based for statement
regular expressions
rvalue references
scoped enums
shared_ptr smart pointer
unique_ptr smart pointer
weak_ptr smart pointer

I would appreciate advice on additional features I should cover and any of the above features you feel are unimportant.

TIA
Bob
 
A

Alf P. Steinbach

Hi folks,

I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.

To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:

array container
auto for type inference
delegating ctors
explicit conversion operators
final classes
final member functions
inheriting base class ctors
list initialization changes
move assignment operator
move ctor
non-deterministic random number generation
nullptr
override keyword
range based for statement
regular expressions
rvalue references
scoped enums
shared_ptr smart pointer
unique_ptr smart pointer
weak_ptr smart pointer

I would appreciate advice on additional features I should cover and any of the above
features you feel are unimportant.

The students should already be familiar with shared_ptr from their
experience with C++03, using boost::shared_ptr and/or the TR1 shared_ptr.

If not then you need to cover that first, it's C++03 stuff.

Then unique_ptr (pure C++11) as replacement for now deprecated auto_ptr.

That covers the most important FUNCTIONAL CHANGES of the language, how
to manage dynamically allocated objects.

Then, considering what I use most,

1. "auto" (especially for function declarations and constants),

2. rvalue references and move semantics with std::move, move
constructors and move assignment, and new conventions for argument
passing (by value is often very OK) and function results (not const)

3. std::function and lambdas


I use range-based loops all the time but if you have to choose, then as
above.

As a general guideline, use the teaching time on what the students need
to understand and can benefit from discussing, don't waste that time on
what they can simply read up in Wikipedia, blogs and the holy Standard
-- or MSDN Library -- even if a buzzword checklist might impress. ;-)


Cheers & hth.,

- Alf
 
W

woodbrian77

Hi folks,



I am finally covering some of the new C++ features in my C++ course. I am interested in getting input from the C++ community as to the priority of new features to cover.



To give you some idea of the features I am planning to cover, these are some of the new features I plan to cover:



array container
auto for type inference
delegating ctors
list initialization changes
move assignment operator
move ctor
nullptr
range based for statement
rvalue references
scoped enums
unique_ptr smart pointer

I use the above and also use non-static data member
initialization. I haven't come across the need for
shared_ptr. I haven't used explicit conversion
operator's, but am interested in learning about
that.

Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
 
K

K. Frank

Hi Bob!

Hi folks,

I am finally covering some of the new C++ features in my C++ course.
I am interested in getting input from the C++ community as to the
priority of new features to cover.

First off, without knowing more about the context of your
course -- purpose, length, students' previous programming
experience, students' previous c++ experience -- it's hard
to give appropriate advice.

Also, it sounds like you're already well along in your course
and coming up to the c++11 section, so my answer is probably
too late.

But I would turn things around and just teach c++11 as c++,
and use various c++ features (including c++11 features) as
appropriate. The c++11 standard was ratified already a couple
of years ago, and largely complete drafts and compilers
supporting much of the new functionality were available
already a couple of years before that, so c++11 should hardly
be looked upon as some mysterious bleeding edge thing.

Quoting Stroustrup in his c++11 faq:

What do you think of C++11?

That's a (to me) amazingly frequent question. It may
be the most frequently asked question. Surprisingly,
C++11 feels like a new language: The pieces just fit
together better than they used to and I find a higher-
level style of programming more natural than before
and as efficient as ever.

(Of course, he's a partisan.)

Although they might be considered syntactic sugar, a lot of
c++11 features are there to make programming more convenient
on a routine, day-to-day basis. (I'm thinking of things
like auto, range-for, in-class initialization, uniform and
list initialization, etc.)

If we as a community continue to adopt cleaner, better c++11
idioms as opportunity permits, and encourage our colleagues
(and students) to do the same, the language in the field
will get -- well -- cleaner and better.

And what better place to start than in a c++ class.

So rather than teach students -- I won't call them bad,
but rather less-good -- pre-c++11 habits and then tack
on some c++11 features at the end of the course, why not
just teach c++11 best practices from day one?

I recognize that some will argue that a lot of real-world
c++ is pre-c++11, but a lot of real-world code is java,
and python, and c. So I say why not teach your student
the best, cleanest programming style and idioms, making
use of language features (whether c++11 or not) that
support that style and those idioms, even as we recognize
that students will come across, and sometimes need to work
with, other programming styles, dialects, and languages.

That's my perspective, at least, although it may not be
appropriate for the context and purpose of your specific
class.
...
TIA

Bob


Good luck.


K. Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top