Skip to content

Instantly share code, notes, and snippets.

@Adobe-Android
Last active September 17, 2020 17:28
Show Gist options
  • Save Adobe-Android/dc78fd9679e91dc4d0f2a3e826491205 to your computer and use it in GitHub Desktop.
Save Adobe-Android/dc78fd9679e91dc4d0f2a3e826491205 to your computer and use it in GitHub Desktop.
A simple demonstration of inheritance
#include <iostream>
struct Superclass {
int x{};
};
struct Subclass : public Superclass {
public:
int y{};
int foo() { return x + y; }
};
int main() {
Subclass sub;
sub.x = 2;
sub.y = 2;
std::cout << sub.foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment