When should I use Vectors/Classes? They can both hold methods/multiple datatypes.
Printable View
When should I use Vectors/Classes? They can both hold methods/multiple datatypes.
When you feel that they would make your life easier.
Vectors are CONTAINERS, classes are OBJECTS, it's like comparing baskets and basketballs.
They are different in the way that vectors are merely containers, they have a collection of objects and the only methods they have are the ones used for traversing/manipulating that collection of objects. With classes you define new objects by defining the objects methods and data members. With vectors you can't define anything. In the end it all comes down to the fact that a vector object is an instance of a vector class.Quote:
Originally Posted by Ideswa
cheers
>> They can both hold methods/multiple datatypes.
vectors cannot hold multiple datatypes at the same time, classes can have many different types as members. vectors cannot hold methods other than perhaps function pointers or function objects, classes can of course have many different member functions with different signatures.
They are completely different tools.