Our test program is a simple variant of the earlier one:
The usage is different than with the C version, though only in a minor way. Depending on the compiler, the C++(www.cppentry.com) version is anywhere from 40 percent to four times slower than the C version on a large input file of 30,000 lines with about 25 fields per line. As we saw when comparing versions of markov, this variability is a reflection on library maturity. The C++(www.cppentry.com) source program is about 20 percent shorter.
Exercise 4-5. Enhance the C++(www.cppentry.com) implementation to overload subscripting with operator [] so that fields can be accessed as csv[i].
Exercise 4-6. Write a Java version of the CSV library, then compare the three implementations for clarity, robustness, and speed.
Exercise 4-7. Repackage the C++(www.cppentry.com) version of the CSV code as an STL iterator.
Exercise 4-8. The C++(www.cppentry.com) version permits multiple independent Csv instances to operate concurrently without interfering, a benefit of encapsulating all the state in an object that can be instantiated multiple times. Modify the C version to achieve the same effect by replacing the global data structures with structures that are al- located and initialized by an explicit csvnew function.