|
A C++ class (or structure) is like a C struct on steroids. That is, it may have functions (methods) as members, as well as variables. If you recall your C structure, you'll recall that it's a programmer-defined type that can hold variables of differing types (strings, integers, etc.). This gives you the opportunity to aggregate a definition in one place and use it repeatedly. If you move one, every attribute (name, age...) automatically moves with it. Sort on any attribute you like. Think of a C struct with the personal information and an array of those structs representing the entire collection. Nothing daunting there. Same with a class in C++. If you don't want to worry about overloading I/O operators and so forth, forget that part; just use it as a struct for organizational purposes. A collection of arrays will work, of course, but it's doing things the silly way. Of course, only you can decide whether or not you want to advance.
It's not very productive to come here and say, "ERRORS, OMG !!!!!111", without saying what kind of errors you're getting; it requires your respondents to examine your code in detail and possibly compile and run it when they might well solve your problem in 7.5 seconds flat if you only describe it.
|