Home > front end >  How can a vector of integers hold objects if an integer is not a class?
How can a vector of integers hold objects if an integer is not a class?

Time:01-31

While I was reading C primer fifth edition I came across this definition of a vector:

A vector is a collection of objects, all of which have the same type. Every object in the collection has an associated index, which gives access to that object. A vector is often referred to as a container because it “contains” other objects.

If I have a vector of integer values then what class do all these objects belong? Because "int" is not a class as these answers from this link already explain:

Is int (built in data types) a class in c ?

I also came across the concept of "Data Objects" from IBM, are these the objects that the vectors hold in this case? Because I have been reading this concept of "Data object" a lot and it still puzzles me. And even if it is the object that the vectors hold, my question still remains: what class does it belong?

CodePudding user response:

If I have a vector of integer values then what class do all these objects belong?

No class at all. The elements of a vector of integers are objects of the integer type. Integer types are fundamental types.

  •  Tags:  
  • Related