notes from quizlet + friends
+ operator can be defined as a function too
C++ doesn’t define what operators mean with respect to objects (EX: how do you add objects?)
classes are private by default, so to make it public you have to be sure that you want it public
structs are automatically public
friend functions / data members (variables) are like giving access to certain varibles outside of a class to a SPECIFIC other class
2D vectors: use cases and declaration
vectors
with arrays, you can do dynamic memory allocation. with vectors, array in the backend but you cna change the size dynamically, can access things usies an index
declare a library for vectors
vectors are an o(1) process, so they’re efficient
arrays are O(n)
need to start with at least something in vector if you dont give a size so that it exists. before you use it.
parsing:
ifstream: file based input.
cin, ifstream, stringstream → different ways to get C++ input
try/check/use → is the input valid?
cin.fail(), ifile.fail()
ifstream first, then ifile
ofstream → cout version of ifstream (with ofile)
ofile.close() → always close newly created files!!
parsing → stringstream. parsing a string. means taking pieces of it.
.getline
const = things that won’t change. constant values.
virtual =