Passing to functions 240711 new copy of the object

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e data to a method. Must be a fixed size. Passing to functions: : ì 24/07/11 new copy of the object. // Create another car, and add it. Car otherCar("Ferrari"); myCars.push_back(otherCar); otherCar.setMake("Pinto"); Initialization list calls 1 argument constructor. string myStudentNames[100]; int myStudentAges[100]; ì push_back()... Create a and places it in the vector. // Add a new car. myCars.push_back(Car("Porsche")); Able to directly access methods of the array elements with [#].method() Person myStudents[100]; ì Vector Element Access // Create empty vector to store cars. vector<Car> myCars; Array of Objects vs Multiple Arrays ì ì : This creates an array of two objects, using the default constructor for each 24/07/11 Vector of objects Can add/remove elements at run-time, Knows how many elements it is holding. Arrays of objects, or vectors of objects, are great for object-oriented programs. 20...
View Full Document

Ask a homework question - tutors are online