Skip to content

Intro to C++, learning to do things you can already do in Java

Notifications You must be signed in to change notification settings

MiamiOH-CSE274/02_Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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.

I will lecture about this material in class. These readings are meant to be used in reviewing/studying.

  1. 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)
  2. 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"
  3. 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)
  4. Bitwise operators. https://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Variables/Operators#Bitwise_operators (2p)
  5. 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)
  6. 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.
  7. 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

  1. Fork this repo
  2. 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.
  3. Be sure to git commit and git push often
  4. Update this file with your documentation and the answers to questions.
  5. When you are ready to turn in your homework, submit a pull request from your repo to mine.
  6. 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.

  1. prime - TODO
  2. defix - TODO
  3. sumSlice - TODO
  4. square - TODO
  5. listPrimes - TODO

Questions

1. In C++, the compiler compiles each .cpp file separately, without looking at the others. Explain why this leads to the need for .h files.

2. Explain the individual roles of the preprocessor, the compiler, and the linker. What type of inputs do they take? What kind of outputs do they produce? What is the purpose of each?

3. What is a "pointer"?

4. If I have a variable declared as int x, how do I find out what memory address that variable is stored at?

5. If I want a variable p that can store the address of an int, what type should I declare p to be?

6. Just like Java, C++ has a new command. But C++ also has a delete command that Java does not have. Why do we need delete in C++, but not in Java? What is delete good for?

7. What is one question about C++ that you would like me to explain in class?

About

Intro to C++, learning to do things you can already do in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages