Last active
May 1, 2016 20:34
-
-
Save bugaevc/e2fc865c83700583c92ea9afc9e82362 to your computer and use it in GitHub Desktop.
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
struct A { | |
int x; | |
}; | |
struct B: A { | |
int y; | |
}; | |
struct C: B { | |
int z; | |
}; | |
B func(B arg) | |
{ | |
return arg; | |
} | |
int main() { | |
A a; | |
B b; | |
/* this works fine: | |
* a B value is a valid A value | |
* to put it another way, you can use a B value | |
* whenever an A value is expected | |
*/ | |
a = b; | |
/* on the other hand, | |
* this would be an error: | |
*/ | |
// b = a; | |
// this works just fine | |
C arg; | |
A res = func(arg); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment