Last active
October 10, 2024 17:23
-
-
Save Tonaion02/05c9de7139340173c9b0200ceab1a48e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Class that must be inherited (START) | |
struct A { | |
int a; | |
}; | |
// Class that must be inherited (END) | |
// Class that must inherit from A(parent class) (START) | |
struct B { | |
struct A super; | |
int b; | |
}; | |
// Class that must inherit from A(parent class) (END) | |
int main() { | |
struct B b; | |
// I don't have to access in this manner | |
b.super.a = 10; | |
// I can access in this manner | |
struct A* generic_ref = (struct A*)&b; | |
generic_ref->a = 10; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment