Getting ready

We will require a couple of files for this recipe. Let us start with the C++ implementation and interface. We will place these in a subdirectory called account/implementation. The implementation file (cpp_implementation.cpp) is similar to that in previous recipes but contains additional assert statements, since we will keep the state of the object in an opaque handle and we will have to make sure that the object is created before we try to access it:

#include "cpp_implementation.hpp"#include <cassert>Account::Account() {  balance = 0.0;  is_initialized = true;}Account::~Account() {  assert(is_initialized);  is_initialized = false;}void Account::deposit(const double amount) {  assert(is_initialized);  balance += amount;}void Account::withdraw(const ...

Get CMake Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.