CS153/hw5/hw5programs/tc_subtyping8.oat

19 lines
289 B
Text
Raw Normal View History

struct A { int x }
struct B { int x ; int y }
struct C { int x ; int y ; int z }
/* C <: B B <: B */
/* ---------------------- */
/* (B) -> B <: (C) -> B */
B f(B b) {
return b;
}
void g((C) -> B f) {
return;
}
int program(int argc, string[] args) {
g(f);
return 0;
}