This reminds me of an interesting event that occurred in my C++ class. During one of the assignments I looked at a peers code. I became convinced that the code was wrong. His code looked a little like this:
Another student saw the teacher pass him and copied his implementation. His code didn't work. It gave the stack overflow error that I was expecting.
It turned out that the reason the guy had his code work in the first place was because it was never included in the program. He had put the code in his C++ file, but forgot to include it in his header. When the program compiled, it never knew his code existed.
I was teaching one of my good friend C way back in undergrad(1999). After explaining him about loops among other stuff...i asked him to print something in loop. And this is what he wrote
For(i=1 to 10)
{then print i;
}
Today my friend is working as a techie ....senior mgr at his new company!
Another student saw the teacher pass him and copied his implementation. His code didn't work. It gave the stack overflow error that I was expecting.
It turned out that the reason the guy had his code work in the first place was because it was never included in the program. He had put the code in his C++ file, but forgot to include it in his header. When the program compiled, it never knew his code existed.