 
  
   
    2012 Unidata NetCDF Workshop  > Introduction to the NetCDF APIs
 
2012 Unidata NetCDF Workshop  > Introduction to the NetCDF APIs  
 
10.5 The C++ API
The two C++ APIs (legacy and netCDF-4) provide object-oriented access to netCDF data.
Strengths
  - Object-oriented: encapsulation, polymorphism, inheritance, ... 
- Well documented:  legacy C++ Users Guide is complete and
  up-to-date; doxygen-generated netCDF-4 C++ Users Guide available 
- Type safe: better than the C interface
- Concise: less code than equivalent C program, no IDs for variable,
  dimension, or attribute objects
- Easy memory management: allocated by library
Weaknesses
  - Legacy version showing its age: written before C++ standards for templates,
  exceptions, and namespaces
- No easy transition from legacy C++ API to completely different
  netCDF-4 C++ API
- No garbage collection: you have to delete memory allocated by the library
- Less tested than C, Fortran, and Java interfaces
- No ncgen support: ncgen cannot (yet) generate any C++ code.
Other Characteristics
  - Both APIs implemented as a thin layer on top of C library
- NetCDF-4 C++ contributed by Lynton Appel, UK Culham Centre for Fusion Energy
- Not used in other Unidata libraries or utilities
- Separate software distributions since netCDF-C version 4.2
 
 
 
  
   
    2012 Unidata NetCDF Workshop  > Introduction to the NetCDF APIs
  
2012 Unidata NetCDF Workshop  > Introduction to the NetCDF APIs