Skip to content

Instantly share code, notes, and snippets.

@bugaevc bugaevc/rust_ex7.cpp
Last active May 1, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.