Describe output of the following program

can anyone describe the output of the following program, and explain why it is produced. ?? thanks

struct base {
virtual void foo(void) { count << "base" << end1; }
}
struct derived : base {
void foo(void) { count << "derived" << end1; }
}
int main(void) {
base *b = new derived;
b -> foo();
return 0;
}
This program is a mess. It does not include the necessary headers, count should be cout and end1 should be endl, and int main (void) should really be int main().

If all that is fixed, this program creates an object of type derived and calls its foo function.
Last edited on
This program was taken as is directly from last year's final for a programming class and I'm guaranteed to have something similar for my final.
If the person preparing the final exam cannot spell cout and mistakes the letter "l" for the number "1", you've got problems :)
Topic archived. No new replies allowed.