C/C++ Primer
Overview
This mini class is a short primer that will teach you the basics of the C
and
C++
language features. C
and C++
are compiled programming languages often
used in research as well as in industry. Compared to the Python programming
language, C
is much closer to the hardware which is important if you start to
consider lower-level optimizations for performance (essential for High
Performance Computing (HPC) applications). Knowing the fundamentals of C
and
C++
is a valuable skill to have in your backpack.
Outline
The mini class is voluntary and not graded. It will consist of lecture components that teach you the essentials along with embedded hands-on exercises that will take place interactively during class. You are required to bring your laptop and should have some intuition and comfort in using the command line (know how to navigate, create files and directories as well as being able to edit files with an editor or IDE of your choice). You will not be given homework for this mini-class.
The main motivation to offer this primer is to ensure a common ground for students who plan on taking CS205 next spring. Some C/C++ background will be necessary for CS205. The primer can not provide this in full but aims at refreshing the basics that have been studied some time ago. Of course you are welcome to join if you do not intend to take CS205.
The primer consists of 10 lectures at about 60 minutes duration. Since it is a voluntary event, these lectures will be held in the evening to avoid possible conflicts with your schedule.
Participation and Registration
Everybody is welcome to join this mini class.
Registration
You can register for the class by joining our mailing list. Subscriptions are open now until October 4th, 2021. You can enroll the mini-class by sending an email to
iacs-primer-join@lists.fas.harvard.edu
with subscribe
in the subject. You will be asked to confirm your
enrollment.
If you have questions about the class, you can send an email to
iacs-primer@lists.fas.harvard.edu
This is a mailing list, messages will be sent to all subscribed students such that they can benefit from these questions as well. You can send direct questions to this email.
Schedule and Location
Location: SEC LL2.224 SU Family Classroom
Time: 6:30PM - 7:30PM
Date: * 10/18 - 10/22 (week 42) * 10/25 - 10/29 (week 43)
Meeting times: The mini-class takes place during calendar week 42 and 43. Lectures are held on each week day (Mon-Fri) from 6:30PM - 7:30PM (depending on discussions during the lectures, you may need a bit of additional padding regarding the 60 minute duration).
Lecture Content
Lectures 1-4 discuss basic concepts that were first introduced in C
. Lectures
5-10 focus on C++
specific language features that are not available in C
.
Class repository on GitHub: https://github.com/Harvard-IACS/c_cpp_primer
Lecture 1 (10/18/2021)
- Procedural languages and Object Oriented Programming / General overview
- Compiled languages / Stages of code compilation / Get to know your compiler
- Building code /
make
/meson
/cmake
Lecture 2 (10/19/2021)
- Basic built-in types
- Arrays
- Pointers
- Pointers are not arrays
Lecture 3 (10/20/2021)
- Pointers and dereference operator
- References (C++ specific)
- Basic operators and operator precedence
- Functions and function pointers
- Anonymous functions / Lambdas (C++ specific)
Lecture 4 (10/21/2021)
- Function arguments: Pass-by-value / Pass-by-reference
- Memory allocation
- Stack and heap
- Input/Output (IO) / Streams
Lecture 5 (10/22/2021)
- Object Oriented versus Data Oriented designs / Where is
C++
good at and where can it hurt you - Classes: Constructors / Destructors / Members / Attributes / Initializer lists
- Data Encapsulation / Difference to procedural programming
Lecture 6 (10/25/2021)
- Resource Acquisition Is Initialization (RAII)
- Operator overloading
- Inheritance and the
this
pointer
Lecture 7 (10/26/2021)
- Access modifiers
- Base class pointer
- Polymorphism and interfaces
Lecture 8 (10/27/2021)
- Abstract base classes
- Pure virtual methods
- Operator overriding
Lecture 9 (10/28/2021)
- Generic programming
- C++ templates
- Implementation approaches
Lecture 10 (10/29/2021)
- Standard Template Library (STL)