Skip to content

Instantly share code, notes, and snippets.

@mcpherson mcpherson/

Created Mar 27, 2016
What would you like to do?
Test static pointer to instance member (for use in callback function)
// Test static pointer to object member from callbacks
// g++ -std=c++11 -g -O3 -o statmem
#include <iostream>
class Test;
static Test *bug;
class Test {
int val;
static void ccback(void) {
std::cout << bug->val << std::endl;
void cback(void) {
std::cout << bug->val << std::endl;
int main() {
Test test;
test.val = 10;
bug = &test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.