Week 14.pptx - Object-Oriented Programming(OOP Week \u2013 14 May 18-22 2020 Instructor Basit Ali Email [email protected] Object-Oriented

Week 14.pptx - Object-Oriented Programming(OOP Week – 14...

This preview shows page 1 - 5 out of 20 pages.

Object-Oriented Programming (OOP) Week – 14 May 18-22, 2020 Instructor: Basit Ali Email: [email protected] Object-Oriented Programming (OOP)
Image of page 1
Vectors The vector class simply provides a dynamic array i.e. an array that can grow as needed Vectors allocates memory when needed Although a vector is dynamic, we can still use normal array syntax to access its elements
Image of page 2
Advantages of Vectors The size of a vector does not have to be a fixed constant, and it can also grow or shrink during execution. If you want to read data from a file and store it in an vector, you can just keep adding new elements as you receive them, without having to know what the largest amount would be A vector always knows its own size, so passing one to a function does not require you to separately pass this information Elements can be accessed by position in a vector just as they are in an array, but you can also insert and remove elements anywhere in a vector Vectors can be returned from a function easily
Image of page 3
Library
Image of page 4
Image of page 5

You've reached the end of your free preview.

Want to read all 20 pages?

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes