swig/Examples/go/callback/example.h
Michael Schaller 85037c3a33 [Go] Updated the 'callback' and 'extend' examples to match the 'director' one.
After the documentation update on how to utilize the director feature with
commit @17b1c1c the 'callback' and 'extend' examples needed an update as well.
2015-08-09 14:37:16 +02:00

22 lines
527 B
C++

/* File : example.h */
#include <cstdio>
#include <iostream>
class Callback {
public:
virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
virtual void run() { std::cout << "Callback::run()" << std::endl; }
};
class Caller {
private:
Callback *_callback;
public:
Caller(): _callback(0) {}
~Caller() { delCallback(); }
void delCallback() { delete _callback; _callback = 0; }
void setCallback(Callback *cb) { delCallback(); _callback = cb; }
void call() { if (_callback) _callback->run(); }
};