Week 1 Day 2 - A Little Advanced C++...

Channel:
Subscribers:
2,640
Published on ● Video Link: https://www.youtube.com/watch?v=ktPpsqiSp58



Duration: 1:04:50
44 views
0


The Voroni assignment was due today, but some of the students had technical issues completing it, so I went over some features of C and C++ that they hadn't seen before. (This is one of the reasons why I recommend my CSCI students take game development - they continue to level up in programming.)


We talked about:


1) static inline class variables - variables that are attached to a class, not an object of that class. So all objects of that class share the same variable.


2) The use of #if and #ifdef and related preprocessor directives to do things like cause compiler errors if the version of C++ used wasn't high enough, or to have different function calls on different operating systems.


3) Using a reference to get a variable out of a vector without actually copying it out as normal. This can be risky as if a vector ever reallocated all pointers, references, and iterators pointing at it are invalidated.


4) Use of typedefs (or using "using" in C++) to alias type names to a smaller size.


5) Globals are always initialized to 0


6) Using emplace_back instead of push_back. I don't mention why in the video - we do this to avoid creating a temporary variable and then copying the variable into the vector.


I start the lecture talking about one of the most unconscionable employment agreements I've ever seen from Amazon, and I finish the lecture talking about the UCs, discrete math, and some other stuff you can skip.







Tags:
is50b
amazon
c++
ucsd