I was wondering. Lets say you have a class, we'll call it Person. This Person class has several data members, string FirstName, string LastName, int age. Now, lets say you want to create..... 50 Person objects and store them into a container. This seems practical, if you want to sort, all you need is any part of that Person object and you get all the data of that object. Here's my question. Would it be better to instead have seperate containers for each data member and have an array that solely stored the string FirstName's and so on? This would give you two string arrays, string FirstName[size], string LastName[size], and int age[size]. I'm curious if this would further complicate the problem of data management or if sticking with the class idea would be the best way to handle the data? I know this may sound confusing but I was curious.
Here's my question. Would it be better to instead have seperate containers for each data member and have an array that solely stored the string FirstName's and so on?
No.
Look at it this way.
The B programming language only had one type, the machine word. You could craft what you liked out of it, but there comes a time when you spend more time bending that type into the type you need than doing what you want to do. Enter C.
The C programming language introduced a set of types that mapped onto the then new computers that were coming out. It introduced int (short and long), floating point types and char (for a byte), with those types revised as the hardware and language are revised. But then we use those types for our own purposes, and we're back to spending more time on bending those machine types into types that we need than doing what you want to do. Enter C++.
The C++ programming language allows you to create user defined types that have all the protections given to built in types. Once your you make up a type, you can forget about it, you don't need to keep going back and checking, "Will it work here?" or "Will it work there?", it works pretty much everywhere.
So back to your example, once you define your Person class, that's it. Don't break it up. In your case of sorting Persons, the standard sort function takes a functor that specifies how the container should be sorted. You can specify different functors or functions for different sort orders. So Person remains intact and you specify the sort order externally.