Byte-Sized-Chunks: C++ Templates and the STL

Compile-time polymorphism via templates, C++ casts, containers, algorithms and iterators - all will make sense now!
3.9 (4 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
29 students enrolled
Take This Course
  • Lectures 15
  • Length 2 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2016 English

Course Description

Note: This course is a subset of our much longer course 'Learn By Example: C++ With 75 Solved Examples' so please don't sign up for both:-)

Like a gruff uncle, C++ seems intimidating, when its just being helpful. These examples will help you understand that.

Let's parse that.

  • C++ seems intimidating because all too often, what you see is not what you get.
  • Usually, that's because C++ is trying to help you, but you don't realise that. C++ is incredibly deep, and it sometimes struggles to get you - the programmer - to understand what it's saying
  • These examples will help. Each is self-contained, has its source code attached, and gets across a specific C++ use-case. Each example is simple, but not simplistic.

What's Included:

  • Templates are a classic generic programming technique that were revolutionary when first added to C++. Understand template functions and classes, as well as template specializations.
  • STL - the Standard Template Library - is incredibly powerful. Get a good sense of collections, iterators and algorithms - the major components of the STL
  • C++ casts are quite different than C-casts. Understand const_cast, static_cast and dynamic_cast, as well as Real Time Type Identification (RTTI), and the manner in which explicit conversions can be performed using static_cast

Talk to us!

  • Mail us about anything - anything! - and we will always reply :-)

What are the requirements?

  • Students should have an understanding of programming - concepts such as variables, loops and if-else statements will not be explained
  • Students should have some basic working knowledge of C++, Java or C#

What am I going to get from this course?

  • Confidently use templates - in the form of functions, classes and casts - to write generic C++ code
  • Leverage the power of algorithms, iterators and containers in the STL
  • Understand how templates make the C++ casts so much more powerful than C-style casts

Who is the target audience?

  • Nope! Please don't enroll for this class if you have already enrolled for our 15-hour course 'Learn By Example: C++ Through 75 Solved Examples'
  • Yep! Java and C# programmers - who understand Object Oriented Programming, but are new to C++
  • Yep! Folks with prior programming experience in C. Some prior object oriented programming experience is recommended
  • Yep! C++ programmers looking to get the little details of templates and the STL exactly right

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Buzzing Like Bees:Templates!
You, This Course, and Us!

Templates are an awesome way to reuse code in C++. They are the basis of the Standard Template Library, and are a form of compile-time polymorphism.

Just so we wrap our heads around the idea of a function template, and a template parameter.

What happens when we wish to override the default template instantiation for some specific type? Its easy!

Possibly the most interesting example in this course: a smart pointer class, built using template classes. Smart pointers are used very widely, so you should really make sure to understand this example.
Total and partial template specialisations are not at all as scary or complicated as they sound.
Section 2: STL - The Standard Template Library
The STL is a little universe of its own, powerful, and elegant. Its really worth your while learning about the STL - it has way too much cool stuff that folks don't use because they find it a bit..intimidating.
The STL vector class is the most commonly used container, and with good reason.

Iterators sound boring ("classes to do stuff, element-by-element with contents of a container") but that bland description belies their power and utility.


We already explored the vector, which is a sequential STL container - now, let's do some stuff with the map, an associative container.

Algorithms are the most powerful - and least widely used - part of the STL. Let's see how they work. Oh, and did you know that the C++ string is actually an STL container, with some clever typedefs so that you are n't scare off by it?
Section 3: C++ Casts

C++ casts are surprisingly versatile. Understand the 4 types of casts, and how they each differ from old-school C-style casts (which you should entirely stop using, btw)

The const_cast eliminates constness..
..dynamic_cast is the only safe way to downcast (i.e. to go from base class to derived class). It makes use of the RTTI, C++'s Runtime Type Identification System.
static_casts are quite smart too - its just that they perform their magic at compile-time, not runtime. Learn how they work with the explicit keyword and make conversions work.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Loony Corn, A 4-person team;ex-Google; Stanford, IIM Ahmedabad, IIT

Loonycorn is us, Janani Ravi, Vitthal Srinivasan, Swetha Kolalapudi and Navdeep Singh. Between the four of us, we have studied at Stanford, IIM Ahmedabad, the IITs and have spent years (decades, actually) working in tech, in the Bay Area, New York, Singapore and Bangalore.

Janani: 7 years at Google (New York, Singapore); Studied at Stanford; also worked at Flipkart and Microsoft

Vitthal: Also Google (Singapore) and studied at Stanford; Flipkart, Credit Suisse and INSEAD too

Swetha: Early Flipkart employee, IIM Ahmedabad and IIT Madras alum

Navdeep: longtime Flipkart employee too, and IIT Guwahati alum

We think we might have hit upon a neat way of teaching complicated tech courses in a funny, practical, engaging way, which is why we are so excited to be here on Udemy!

We hope you will try our offerings, and think you'll like them :-)

Ready to start learning?
Take This Course