This post describes how to use structured data types. Structured data types allow you to group related data together so that it can be passed around easily.
vectors as members of
structs with a
- Calculus with
Now that you have reviewed the guided code walk-throughs I ask that you write a program that has a struct to represent a cell phone. Every cell phone has a model name and manufacturer along with a camera with a mega-pixel resolution. For example, I may want to store information about an Apple IPhone X with a 12 MP camera or a Google Pixel 4 with a 16 MP camera.
Your program will create three cell phone objects, fill them, and then add them to a vector. Lastly, print out the information about each cell phone on the screen.
Write a function that takes a cell phone object by reference and prompts the user to enter in the model, manufacturer, and camera resolution. Write another function that prints information about a cell phone. Write a function that takes a vector of cell phones and prints each one.
You can find all of these code playbacks in my free 'book', An Animated Introduction to Programming in C++. I am always looking for feedback so please feel free to comment here or to send me a message. You can follow me on twitter @markm208.