Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 1.23 KB

README.md

File metadata and controls

24 lines (17 loc) · 1.23 KB

C++ Callback Example

A basic implementation of a C++ callback function.

Some Specifics

This example considers the case where a C++ class has a member class that performs various operations. The main class is called WrapperClass and the other is called MemberClass. The operations of MemberClass encounter events that require a callback to a method in WrapperClass.

In C++ 11 it is possible to use std::function and std::bind as seen in this example. However, this repo contains a general solution for all C++ versions. Therefore, the desired callback method needs to be passed to MemberClass in the form of a method pointer.

A working example with comments is provided.

Run Commands

cd build/
cmake ..
make
./cpp-callback

Resource Links