9.3 The C++ API
The C++ library provided the first object-oriented API for netCDF.
- Object-oriented interface
- Fairly well documented: Users Guide is complete and up-to-date.
- Type safety: better than the C interface.
- Less code than an equivalent C program.
- Short argument lists, because there are no IDs for variables,
dimensions, or attributes.
- Easier memory management, because space for blocks of data is allocated
by the library.
- Showing its age: written before C++ standards for templates,
exceptions, and namespaces
- No garbage collection: you have to delete blocks of data and
NcAtt objects (attributes) allocated by the library when done with them.
- Less tested than C, Fortran, and Java interfaces.
- No ncgen support: ncgen cannot (yet) generate any C++ code.
- Old-fashioned error handling: no C++ Exceptions used, so need to check
return status from method calls.
- Implemented as a thin layer on top of C library
- Not used in other Unidata libraries or utilities.
Annotated examples of complete C++ netCDF programs are available from
the program examples page.
NetCDF-4 note: An experimental new
netCDF-4 C++ API,
contributed by Lynton Appel, is available in the current beta release.