Skip to content

Instantly share code, notes, and snippets.

@gidden
Created January 16, 2014 04:25
Show Gist options
  • Save gidden/8449776 to your computer and use it in GitHub Desktop.
Save gidden/8449776 to your computer and use it in GitHub Desktop.
reference member from multiple base classes
#include <iostream>
class Base1 {
public:
int index;
Base1() : index(1) {};
};
class Base2 {
public:
int index;
Base2() : index(2) {};
};
class Derived : public Base1, public Base2 {};
int main () {
Derived d;
std::cout << d.Base1::index << std::endl;
std::cout << d.Base2::index << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment