Skip to content

A basic implementation of a C++ callback function.

License

Notifications You must be signed in to change notification settings

jdmillard/cpp-callback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A basic implementation of a C++ callback function.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published