Created
January 16, 2014 04:25
-
-
Save gidden/8449776 to your computer and use it in GitHub Desktop.
reference member from multiple base classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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