If you don't understand the difference between an object and a type, then you're going to be in all sorts of trouble. It's absolutely fundamental to programming in C++, or in any typed language.
In a nutshell, consider the following statement:
is on object. It corresponds to a particular piece of memory, containing specific values.
is a type. It tells us something about how the values stored in memory are treated.
(Yes, it's unusual to consider a variable of a primitive type as an "object", but conceptually that's what they are.)
You can change the value of i - for example:
int i = 0;
i = 2;
i = 3 + 1;
You cannot change the value of int, because int is not an object with a value. It is simply a type:
int = 1; // THIS MAKES NO SENSE
Nor can you read the value of int, because it has no value:
std::cout << "The value of int is " << int << std::cout; // THIS MAKES NO SENSE
i and j are two different objects. They correspond to different bits of memory, and hence can hold different values.
i and j have the same type. They are both int. They share the same behaviour, but hold different values.
Now consider the following, from your code:
Here, you are declaring an object. Its name
. Its type
is an array of
objects - in other words, its type is a pointer to
Now look at your line:
if (infoType.lname[j] != "" && infoType.lname[smallest] != "")
is a type. Semantically, it is the equivalent of
. It has no value. It cannot be array-indexed. It cannot be read. It cannot be set to a value.
The name of the object that you have passed into your sort function is
. That is the thing you should be looking at the values of.