Skip to content

CPP for Intermediates

Andrew Cua edited this page Oct 6, 2022 · 2 revisions

This page will have CPP resources broken up by topic and will be most helpful to those who already have a good understanding of Java or OOP in general.

Topics

Primitives

primitives in C++ are very similar to those in Java with some minor differences.

  • boolean is changed to bool
  • long is a modifier on int so long int would be long in java. They can be chained however so you can have long long int for a datatype even bigger than Java's
  • strings are not considered a primitive. you'll need to #include <string> to get access to std::string which operates similarly to Java's string.

Classes and Structs

for an examples go to W3Schools

  • Structs work the same as Classes, just replace class with struct
  • observe the semicolon at the end of the last }

The main difference between Classes and Structs is that Classes have private attribute visibility by default while Structs have public attribute visibility by default.

  • in practice we use classes like in Java, while we use structs as data classes.

Classes in our code base are separated into 2 files a *.cpp file and a .h file. h files are header files which contain declaration details while the cpp files contain the implementation.

for more detail see this pdf

Vitrtual and Inheritance

Functions

Pointers

Smart Pointers

Arrays and Lists

Lambda's

Learning:

if you'd like a course designed to bring programmers up to scope in CPP then Codecademy has a course for CPP designed for people who already have knowledge in programming.

Behaviors

Clone this wiki locally