online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> typedef bool (*PMethod)(void* pContext); PMethod g_pMethod = nullptr; void* g_pContext = nullptr; void RegisterCallback(PMethod pMethod, void* pContext) { g_pMethod = pMethod; g_pContext = pContext; } void UnregisterCallback() { g_pMethod = nullptr; g_pContext = nullptr; } void CallCallback() { (*g_pMethod)(g_pContext); } class CSampleClass { public: CSampleClass() { RegisterCallback(CSampleClass::callback, this); } ~CSampleClass() { UnregisterCallback(); } private: static bool callback(void* pContext) { // Check Context if (pContext != nullptr) { CSampleClass* pSampleClass = static_cast<CSampleClass*>(pContext); pSampleClass->call(); return true; } else { return false; } } bool call() { printf("Callback successfully called\n"); return true; } }; int main(int, char**) { CSampleClass oSampleClass; CallCallback(); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue