O'Reilly logo

CMake Cookbook by Roberto Di Remigio, Radovan Bast

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required