This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/d6704ddbb9f360d6ccd53dc979cc4776 | |
| // Filename cpsc120_words_to_vector.cc | |
| // CompileCommand clang++ -std=c++17 cpsc120_words_to_vector.cc | |
| // Read a file word by word and place contents into a std::vector | |
| #include <fstream> | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/396db34b08fb9d3b553358778d176f56 | |
| // Filename cpsc120_function_pointer.cc | |
| // CompileCommand clang++ -std=c++17 cpsc120_function_pointer.cc | |
| // Demonstrates how to work with functions and member functions as pointers. | |
| // Generally speaking, don't do this unless you need to. You will probably | |
| // find that function objects and lambda expressions will get you more mileage | |
| // in C++ however this knowledge is useful. | |
| #include <iostream> | |
| #include <string> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/00875dc88635dfb640278b2259b19fb3 | |
| // Filename cpsc120_virtual.cc | |
| // CompileCommand clang++ -std=c++17 cpsc120_virtual.cc | |
| // Demonstrates how virtual works in C++ | |
| #include <iostream> | |
| #include <string> | |
| class Fizz { | |
| public: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/80d95db3aeb0de7d181440ce47f32a36 | |
| // Filename cpsc120_animated_image.cc | |
| // CompileCommand clang++ -std=c++17 -I /usr/include/GraphicsMagick cpsc120_animated_image.cc -lGraphicsMagick++ -lGraphicsMagick | |
| // Create a simple, small image from a given filename. GraphicsMagick | |
| // will figure out how to output to the given file format. | |
| // Supported formats: http://www.graphicsmagick.org/formats.html | |
| // Example: | |
| // clang++ -std=c++17 -I /usr/include/GraphicsMagick cpsc120_animated_image.cc -lGraphicsMagick++ -lGraphicsMagick | |
| // ./a.out my_image.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/9218c947894149cabdebadb1a1083000 | |
| // Filename cpsc120_fancy_image.cc | |
| // CompileCommand clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_fancy_image.cc | |
| // Create a simple, small image from a given filename. GraphicsMagick | |
| // will figure out how to output to the given file format. | |
| // Supported formats: http://www.graphicsmagick.org/formats.html | |
| // Example: | |
| // clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_fancy_image.cc | |
| // ./a.out my_image.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/c60dcd64a98e664c6d75115e7f57fe41 | |
| // Filename cpsc120_image_with_text.cc | |
| // CompileCommand clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_image_with_text | |
| // Create a simple, small image from a given | |
| // filename. GraphicsMagick will figure out how to output to the given file | |
| // format. | |
| // Supported formats: http://www.graphicsmagick.org/formats.html | |
| // Example: | |
| // clang++ -std=c++17 -I /usr/include/GraphicsMagick -lGraphicsMagick++ cpsc120_image_with_text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/7dfcb98e197573a97b0766d48af7a6d2 | |
| // Filename cpsc120_food_class.cc | |
| // CompileCommand clang++ -std=c++17 cpsc120_food_class.cc | |
| // Create a vector of objects. The object has multiple data members. | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/759d0d17b0bb03873516dcc9e16f5dca | |
| // Filename cpsc120_2D_vector_pt2.cpp | |
| // CompileCommand clang++ -std=c++17 cpsc120_2D_vector_pt2.cpp | |
| // Create a vector of vectors, the inner vectors contain strings | |
| // Note that C++ is row major order. | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/ff7818bd3514ad0539e90b5d2f8933b3 | |
| // Filename cpsc120_vector.cc | |
| // CompileCommand clang++ -std=c++17 cpsc120_vector.cc | |
| // Working with C++ vectors. | |
| #include <iostream> | |
| #include <vector> | |
| int main(int argc, char const* argv[]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist https://gist.github.com/mshafae/eb239941e0171dcf564d91a3f75c64a7 | |
| // Filename cpsc120_2D_vector.cpp | |
| // CompileCommand clang++ -std=c++17 cpsc120_2D_vector.cpp | |
| // Create a vector of vectors, the inner vectors contain strings | |
| // Note that C++ is row major order. | |
| #include <iostream> | |
| #include <string> | |
| #include <vector> |