Overview

We’ll be using C++ in this class for the most part. The syntax is fairly similar to Java (which some of you know and some of you don’t), with a couple of complications. If you’ve learned about C, that’s great, and a lot of that knowledge will transfer. If you haven’t, don’t worry, I’m only assuming knowledge of Java or Kotlin. If you are more comfortable with Python, I’ve also included a resource aimed at transitioning to C++ from Python, though it is a bigger jump.

The main difference with C++ is needing to manage your own memory, so the learning objectives and resources for today are focused on getting an understanding of that.

Basic Learning Objectives

Before class, you should be able to:

  • Explain the basic idea of a pointer in C++
  • Write a snippet of code that gets the address of a variable
  • Write a snippet of code that dereferences a pointer

Advanced Learning Objectives

After class, you should be able to:

  • Solve basic programming problems in C++ that use pointers
  • Explain how C++ uses & and *

Resources

The following are resources that I think will help you achieve the basic learning objectives; you may only need one of them or all three. Remember that you can also interact with Gemini but you should check the answers provided.

  • Java vs C++ Cheatsheet - Don’t worry about things that don’t sound familiar from Java, just a resource for translating what you know in Java to C++
  • Video on C++ Pointers and References - I recommend watching up to the Arrays of Pointers section (Note, this is an old video, there are probably many better videos now, feel free to find one and share the link)
  • Python to C++ Book Pointers - you might find it helpful to read more of this book, but the Pointers section will be particularly relevant
  • I can’t find good resources on Kotlin to C++, but if you find one, let me know!

Checks

Submit answers to the following through Moodle:

  • What is the syntax for getting the address of a variable in C++?
  • What is the syntax for dereferencing a pointer in C++?
  • What is the basic idea of a pointer?
  • What is an additional reference that you liked for this material?

Please also remember to complete the background survey.