Don't forget to fill out the mid-quarter evaluation at! Your comments really make a difference!


Assignment 1 Due, Assignment 2 Out
November 28

Assignment 2 went out today and is due at 11:59 PM on Friday, December 7. You should download the dictionary.txt file and copy it into your source directory so that you can get everything working. This should be an entertaining assignment that will really bring all the course material together, and I hope you enjoy the final product!

Assignment 1 is due tonight at midnight, so be sure to submit it. As always, I'm available after lecture and my LaIR shift is Wednesday from 8:00 - 10:00PM in case you have any questions.

Assignment 0 Results
November 26

Those of you who submitted Assignment 0 should pat yourselves on the back - you did a remarkably good job! Everyone did very well on the assignment and I'm impressed at your facility with some of the rougher parts of the STL. Everyone who submitted the assignment will receive credit.

Overall, the submissions were excellent, but there were two somewhat frequent mistakes I saw when grading assignments. First, many of you had an off-by-one error while reading in the stop words list that caused the last word in the list to be ignored. The most common errors stemmed from code like this:

	ifstream input("stop-words.txt");
	string line;
		getline(input, line);
		/* ... */

While this looks mostly correct, it's slightly off since the function input.eof will return true as soon as the end of the file is reached, not when a read operation failed from end of file condition. Thus the last input read by getline would be skipped, since the reading code would pull the last string out of the file and then put the stream into an eof state. To fix this, change the call to eof to a call to fail. Also, many of you used a vector<string> to store all of the stop words. This works, but is vastly less efficient than using a set<string> since the vector has linear lookup time while set can use binary search to find elements in logarithmic time.

Great job, and good luck on the last two assignments!

Errata to static Handout
November 25

Handout 14: static contains a small error when discussing static const data members. While you can initialize integral static const data members inside the body of a class, you cannot initialize floating-point data types inside the body of a class. Thus, if you have a static const double, you'll need to use the declaration/definition syntax to initialize it. The error has been corrected in the handout.

Hearts Contest Due, Assignment 1 Out
November 14

Submissions for the CS106L Hearts Contest are due at midnight tonight, so be sure to get them in!

Assignment 1 went out today and is due at 11:59 PM on Wednesday, November 28. Your task is to modify the skip list PQueue from CS106X so that it's const-correct and supports deep-copying and assignment. Be sure to test your code thoroughly before submitting it, since assignment operators and copy constructors have a nasty way of seeming correct even when buggy.

Assignment 0 Due, Hearts Contest Announced
October 31

Assignment 0 is due tonight at midnight - if you're having trouble getting things working, feel free to drop by my LaIR shift tonight from 8:00 - 10:00PM. I'll try to hang around a bit afterwards in case you have some last-minutes issues to sort out.

The CS106L Hearts Contest is now officially open for submissions! This should be a great way to put your newfound C++ skills to the test. The winner will get a $20 iTunes gift card and it should be a lot of fun to see everything in action. All entries are due Wednesday, November 14 at 11:59 PM, so you'll have plenty of time to get everything in working order. Good luck!

ConvertToLowerCase on XCode
October 25

Mac Users - Apparently XCode has a bit of trouble compiling the ConvertToLowerCase code we covered in Wednesday's lecture. It turns out that there are two versions of the tolower function - one from the header <cctype> and one from <locale> - and XCode has a bit of trouble differentiating between the two. To fix this, you'll need to do a bit of compiler-appeasing by changing the line

transform(input.begin(), input.end(), input.begin(), tolower)


transform(input.begin(), input.end(), input.begin(), (int (*)(int))tolower)

The weird syntax (int (*)(int)) is a typecast to a function pointer that accepts an int as a parameter and returns an int. Since the cast exactly matches the C version of tolower, transform will use that version instead of the clunkier C++ locale-conversion function tolower. If you're a bit confused by function pointers, don't worry, since CS106X will probably talk about them later in the quarter.

This error also occurs with the StripPunctuation function from the handout - you'll need to cast the ispunct call to (int (*)(int))ispunct.

By the way, it's not a mistake that tolower accepts an int instead of a char. Since chars are simply one-byte numeric values interpreted as letters, they can be implicitly converted to ints.

Midquarter Evaluations
October 24

We're almost halfway through the quarter now and we'd like to hear your thoughts about CS106L. This is the first time we've ever offered this class, so your comments will really make a difference. If you have a few minutes, please fill out the midquarter evaluation form online at All responses are anonymous and we will take feedback seriously.

Submission Instructions Correction
October 21

In the handout for Assignment 0, the submissions instructions say to submit your work into a folder named "Assignment 1." This is incorrect - you should submit Assignment 0 into the Assignment 0 folder. I temporarily forgot that assignments are zero-indexed!

The online version of the handout for Assignment 0 has been corrected accordingly.

City Locator Sample Online
October 17

The city locator example from lecture is now online! Feel free to experiment with modifications, extensions, and anything else you feel like. The code is more commented now than when we saw it in lecture, and hopefully that will make it a bit less intimidating. Before running it, make sure you include the data file in the same directory - otherwise you'll have a whopping zero cities to work with.

If you're having trouble getting the code working, or want to show off some clever modifications you've made, send me an email!

Assignment 0 Out
October 17

Assignment 0: Tag Clouds, Take II went out today and is due on October 31, 11:59PM. Your task is to rewrite the CS106X Tag Clouds program from the CS106X ADTs assignment using only Standard C++. This assignment shouldn't be too difficult; you've already written the core algorithm, and all you really need to do is pull out one set of libraries and switch to another.

While you can probably write the bulk of the code with the material covered in today's lecture, there are a few tiny functions you might have some trouble with. For example, with the loss of strutils.h, you won't have access to ConvertToLowerCase, and without Scanner you won't be able to tokenize input without picking up trailing punctuation. Next week when we cover STL algorithms, though, you'll see how to write slick code that solves both these problems, so don't worry if you're stuck right now.

Feel free to email me any questions you might have about the assignment. Also, my LaIR shift is Wednesday, 8 - 10:00PM, so if you're really stuck you can drop by and get some help. Good luck!

Welcome to CS106L!
September 26

Welcome to CS106L! We've got an exciting quarter ahead of us and you're in for a real programming treat. Please take some time to read over the course information handout just so you're up to speed on my policies and procedures. Classes meet Wednesday from 3:15 to 4:30 in 370-370 and I hope you're able to attend. I'll try to stick around afterwards for a little bit to answer questions so you can get the most out of the class.

This class is appropriate for almost anyone who wants to expand his or her knowledge of C++. If you have only a rudimentary background in C++, this class will quickly fill you in on some of the more advanced C++ concepts and syntax along with a solid understanding of the libraries. For those of you with many years of C++ experience, this class will almost certainly cover topics you haven't been exposed to - after all, C++ is an enormous language!


00: Course Information
01: C++ Standard Library
02: Writing Without genlib
03: C++ IOStream Library
04: C++ Strings
05: C Strings
06: STL Containers, pt. I
07: STL Iterators, pt. I
08: STL Containers, pt. II
09: Assignment 0
10: STL Iterators, pt. II
11: STL Algorithms, pt. I
12: const
13: Initializer Lists
14: static
15: Hearts Contest
16: Copy Ctor, operator =
17: Conversion Constructors
18: Operator Overloading
19: Assignment 1
20: STL Functional Library
21: Inheritance Topics
22: Assignment 2
23: Advanced C++ Topics


Assignment 0: Tag Clouds II
Assignment 1: Professional PQueue
Assignment 2: Evil Hangman
dictionary.txt for Assn. 2


C++ Resources Network
C/C++ Library Reference
Bjarne Stroustrup's C++ Page
CS106X page

Lecture Code

0.0: Basic cin usage.
0.1: oct, dec, and hex.
0.2: Printing a table.
0.3: Integer removal.
1.0: simpio.h functions.
2.0: Basic STL stack.
2.1: Basic STL queue.
2.2: int stack time trial.
2.3: string stack time trial.
2.4: push_back time trial.
2.5: push_front time trial.
2.6: Element access time trial.
2.7: Cleanup time trial.
3.0: Basic STL set.
3.1: Basic STL map.
3.2a: The City Finder Example.
3.2b: place-data.txt for City Finder.
4.0: strutils.h functions.
4.1: STL set algorithms.
4.2: Computer Hearts simulation.
5.0: Integer class, version 1.
5.1: Integer class, version 2.
5.2: Constructor time trial.
6.0: Tracer class.
6.1: DebugVector class.
7.0: DebugVector class, pt. II.
7.1: count_if plus functor.
7.2: C strings in an STL set.
8.0: functional example.
8.1: The Engines example.
8.2: Advanced C++: The CRTP.
8.3: Advanced C++: TMP.