02_Cpp
Intro to C++, learning to do things you can already do in Java
Reading
C++ Programming at WikiBooks.
All of the readings are free online, though note that the book is under constant revision. If something looks crazy, ask me about it.
- Why our code is split into .h files and .cpp files: https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/File_Organization (6p)
- What is the :: operator for? https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Scope Stop at "unnamed namespace"
- What does the compiler do? What does it NOT do? What does the pre-processor do? What does the linker do? https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Compiler Stop at "Compile speed" (4p) https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Compiler/Preprocessor (13p) https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Compiler/Linker (4p)
- Bitwise operators. https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#Bitwise_operators (2p)
- Arrays, and the subscript operator. https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#Subscript_operator_.5B_.5D (5p)
- Pointers. https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#address-of_operator_.26 and https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#Pointers.2C_Operator_.2A (9p) Skip the part about multi-dimensional arrays, and the part about pointers to functions.
- Dynamic memory allocation. https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#Dynamic_memory_allocation (4p)
Homework
- Fork this repo
- Use
git checkout
to check out your branch of the project (which is your unique id) - Fill in the blanks in the main.cpp with code that produces the correct result. Read the comments to find out what they ought to do.
- Be sure to
git commit
andgit push
often - Update this file with your documentation and the answers to questions.
- When you are ready to turn in your homework, submit a pull request from your branch in your repo, to your branch in MY repo.
- Be sure to check the pull requests for my repo on github to make sure it worked, and that your work has been submitted.
Documentation
For each of the following functions in main.cpp, tell me whether or not you think it is working in your submission.
- prime - TODO
- defix - TODO
- sumSlice - TODO
- square - TODO
- listPrimes - TODO