Skip to content

Instantly share code, notes, and snippets.

@Tonaion02
Last active October 10, 2024 17:23
Show Gist options
  • Save Tonaion02/05c9de7139340173c9b0200ceab1a48e to your computer and use it in GitHub Desktop.
Save Tonaion02/05c9de7139340173c9b0200ceab1a48e to your computer and use it in GitHub Desktop.
// 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