Table of Contents
C++ References
Programming in C++ is not easy! There are many intricacies and details of the language that, simply put, take time and effort to understand. But fear not! We are here to help you succeed. Please see the following review material for specific notes on common sticky points. As always, ask questions on piazza and in office hours!
-
http://www.cplusplus.com/
is a great general reference resource- Good place to look up information on data structures and classes in libraries you haven’t worked with much
- Make sure you use the c++11 set of functions if that option is there (under member types)
- The member functions section has any functions you have access to within that class. Clicking on a given function will lead you to information specific to using that function (parameters, returns, expectations etc.) as well as an example use.
-
https://www.cppreference.com/
is another reference site similar to the one above. This is a little less beginner-friendly and might be harder to navigate but has much of the same information -
https://learnxinyminutes.com/docs/c++
is a site that is a good general language overview with examples. It is more geared toward someone who is not familiar with C++ syntax but has the conceptual understanding and programming background from another language. This will not tell you how to use specific classes, data structures or functions, but rather provides a “translation” of how a given task is done in C++ -
For Java programmers:
https://www.cs.brown.edu/courses/cs123/docs/java_to_cpp.shtml
is a tutorial for programmers transitioning to C++ from Java.
Comp 11 Review
Coming into Comp 15, we expect some familiarity with the below topics, and so might not cover them in full detail. you will need this information to succeed in this course. The below are notes on various topics from a previous version of Comp 11, or otherwise resources created by TA's to address common confusion. If you are new to Tufts or C++, or if you're just a little rusty, please review these topics.
- Structs
- Pointers
- Recursion
- When programming, especially in C++ or C, it is imperative that you understand how programs use memory. We will use memory diagrams to help. Learn to draw them.
Comp 15 Course Resources
There are a number of reference resources that provide supplemental or required reading for topics throughout the course.
Course Materials
- Classes, Data Abstraction, and Representation Invariants
- File I/O
- Makefile handout. Much of the same information is packaged as a tutorial in this Makefile.
- Templates
- Linked structures (Note: The linked lists in these notes are done without classes, and they use a slightly different model than those we use in Comp 15. They are like lists in Lisp, Scheme, ML, Haskell, and Erlang. These lists still use the same basic structure, and they show how to do data abstraction without classes, which is how it's done in Comp 40.)
- Brief summary of C++ declarations and references, including reference parameters.
Style Guide
The style guide contains style
and documentation expectations for this course. Every piece of code
you submit for an assignment will
be graded on readability, structure, and organization, as well as
functionality. Therefore it is very important you are familiar with
the expectations in the style guide. We recommend that you
return to the style guide throughout the semester to ensure your code
complies with our style requirements.
Tips for Success
The tips for success document is a
compiled list of things that will help you do well in this course.
Office Hours Guide
The guide to office hours is a
an overview of our procedures for debugging and office hour policies.
Reading this will allow you to make good use of our office hours and
will outline the general expectations we have when helping students.
By following these policies, we can help people better and faster, and
these will make everyone's life easier
FAQ page
The FAQ page will give an overview of some
questions we see come up during the semester. It is a good place to
check if you have a question someone might have asked before!
Debugging
All non-trivial programs have bugs (and most trivial ones do, too). C compile-time errors are often not helpful, and run-time errors are mostly just “segmentation fault” or “bus error.”
Well-written, well-organized code is easier to debug. When debugging, one should think. Many students will reflexively respond to the compiler message “attempt to make int from pointer without a cast” by inserting a cast. Usually, that's not going to fix the problem.
Search engines like Google have really changed debugging: it is very common now to copy and paste an error message one doesn't understand into a search engine and look it up that way. But that is not enough.
You will benefit by becoming familiar with a proper debugger. Runtime error messages are generally uninformative, and sometimes, a flood of print statements won't do the trick. May full-fledged IDEs have integrated debuggers that let you run your program one statement at a time or stop at a particular line in a particular function.
gdb
is the GNU debugger and has a line-oriented interface. It is
available on our department computers, and, while it takes time to
learn, it can be extremely powerful. I use it frequently. (It has
a GUI front end called ddd
, which, alas, is somewhat
abandoned sofware: It has not been maintained and has become
brittle. Nonetheless, it is available on our system. Documentation
is available via the
web
and in a downloadable PDF document. You can
explore it, but perhaps don't rely on it too much.)
Think of a debugger as a replacement for the interactive read-eval-print loop in interpreted environments that you may have used in languages like Python, ML, or Scheme.
We have this resource on debugging memory errors and segmentation faults, which are common bugs you will have to deal with in this class.