4.5.  Review Questions

[ fromfile: lists-questions.xml id: lists-questions ]

  1. Name three applications in which QStringList would be useful.

  2. How can you convert a QStringList to a QString? Why might you want to do that?

  3. How can you convert a QString to a QStringList? Why might you want to do that?

  4. What is the Iterator pattern? Give three examples.

  5. Draw a UML diagram with three or more classes and make sure that all these different kinds of relationships are represented.

    • Aggregation and composition

    • One-to-One and One-to-Many

    • Unidirectional and bidirectional

    The classes should represent real-world concepts, and the relationships should attempt to represent reality. Write a couple of paragraphs explaining why there is a relationship of each kind in your diagram.

  6. What is the difference between composition and aggregation?

  7. Read the API docs for QList and find three distinct ways to add elements to the list.

  8. List three methods that exist in QStringList but are not in QList.

  9. Why does QList have an iterator and an Iterator? What is the difference between them?

  10. Discuss the advantages and disadvantages of Qt or STL container classes as compared with arrays.

  11. Discuss the syntax of the QList declaration. What should be in <angle brackets>? Why is it necessary?

  12. Why does Qt support so many different kinds of iterators?

  13. What is the difference between QFile and QFileInfo?