CIS 330: _ _ _ _ ______ _ _____ / / / /___ (_) __ ____ _____ ____/ / / ____/ _/_/ ____/__ __ / / / / __ \/ / |/_/ / __ `/ __ \/ __ / / / _/_// / __/ /___/ /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / /____/_/ / /__/_ __/_ __/ \____/_/ /_/_/_/|_| \__,_/_/ /_/\__,_/ \____/_/ \____//_/ /_/
the standard template library
Hank Childs, University of Oregon
May 28th, 2014
Any 3F questions?
Now extra credit (1.5%)
No Hank OH week of 6/2
We understand there is a problem, and are doing our best to resolve it.
Don’t forget to email me!!!
I received zero emails after Friday’s lecture
The compiler secretly slips “this” onto the stack whenever you make a method call.
It also automatically changes “myInt” to this->myInt in methods.
So how to does the compiler know?
How does it get “B” for “b” and “A” for “a”?
(X.vptr)(&X, Y, Z);
The 4th virtual function has index 3 (0-indexing)
Secretly pass “this” as first argument to method
The pointer to the virtual function pointer (often called a vptr) is a data member of X
This whole scheme gets much harder with virtual inheritance, and you have to carry around multiple virtual function tables.
Same as B’s
This is how you can treat a C as a B
what do we get?
default arguments: compiler pushes values on the stack for you if you choose not to enter them
The compiler sometimes refuses your inline request (when it thinks inlining won’t improve performance), but it does it silently.
Left: function is inlined in every .C that includes it
… no problem
Right: function is defined in every .C that includes it
… duplicate symbols
Most useful when input is very large and checksum is very small
This will be done with a derived type of Sink.
Note that ~/public_html/3H.png shows up as http://ix.cs.uoregon.edu/~<username>/3H.png
(“~/3H.png” is not accessible via web)