Sealed classes and methods: Difference between revisions

→‎{{header|C}}: Simplified code a bit.
(→‎{{header|C}}: Spoke too soon, just figured out an easy way to do this.)
(→‎{{header|C}}: Simplified code a bit.)
Line 47:
 
void watchMovie(parent *p, typeid id) {
if (id == PARENTCHILD && p->age < 15) {
printf("Sorry, %s, you are too young to watch the movie.\n", p->name);
} else {
printf("%s is watching the movie...\n", p->name);
} else if (id == CHILD) {
if (p->age < 15) {
printf("Sorry, %s, you are too young to watch the movie.\n", p->name);
} else {
printf("%s is watching the movie...\n", p->name);
}
}
}
 
int main() {
parent p = { "Donald", 42 };
9,483

edits