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