The C++Course provides a general introduction to programming in C++. It is based on A.B. Downey's book, How to Think Like a Computer Scientist. Click here for details. |
Home Vectors of Objects The Printdeck Function | ||
The Printdeck Function
for (int i = 0; i < deck.length(); i++) { deck[i].print (); } } By now it should come as no surprise that we can compose the syntax for vector access with the syntax for invoking a function. Since deck has type pvector<Card>, an element of deck has type Card. Therefore, it is legal to invoke print on deck[i].
|
||
Home Vectors of Objects The Printdeck Function |