Help us improve by taking our short survey: https://www.hdfgroup.org/website-survey/

| HDF5 Last Updated on 2026-03-23 The HDF5 Field Guide

Loading...
Searching...
No Matches
C++ API Introduction

Navigate back: Main / Getting Started with HDF5

# Overview

The HDF5 C++ API provides object-oriented wrappers for the HDF5 C Library, enabling modern C++ applications to leverage HDF5's powerful data management capabilities with:

- Automatic resource management through RAII
- Exception-based error handling
- Type-safe interfaces
- STL integration (std::string support)

## Prerequisites

Users should be familiar with:

- HDF5 concepts (files, groups, datasets, attributes, datatypes, dataspaces)
- Basic C++ programming (classes, exceptions, templates)
- The HDF5 Reference Manual for underlying C API concepts

## C API to C++ Class Mapping

The C++ classes closely mirror the HDF5 C API modules:

C API Module | C++ Class | Purpose
--- | --- | ---
H5A (Attributes) | H5::Attribute | Metadata attached to objects
H5D (Datasets) | H5::DataSet | Data storage and I/O
H5S (Dataspaces) | H5::DataSpace | Dimensional structure of data
H5T (Datatypes) | H5::DataType | Data type definitions
H5F (Files) | H5::H5File | File access and management
H5G (Groups) | H5::Group | Hierarchical organization
H5P (Property Lists) | H5::PropList + subclasses | Configuration parameters
H5L/H5O (Links/Objects) | H5::H5Location | Management of links and objects
H5E (Errors) | H5::Exception | Error reporting

## Quick Start Examples

- Creating groups and datasets: h5tutr_crtgrp.cpp h5tutr_crtdat.cpp
- Writing/Reading data h5tutr_rdwt.cpp h5tutr_subset.cpp
- Working with attributes h5tutr_crtatt.cpp

See the Examples from Learning the Basics for additional examples.

## Building Applications

Please refer to the release_docs/INSTALL_CMake.txt file under the top directory of the HDF5 source code or INSTALL_CMake.txt on GitHub for information about installing, building, and testing the C++ API.

Navigate back: Main / Getting Started with HDF5