Hacker News new | past | comments | ask | show | jobs | submit login

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:

  bool operator<(.., ..)
  {
    return operator<(.., ..);
  }
He ran the code and it worked. I was confused.

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.




In gcc this would not give a stack overflow error.


(Depending on your optimization settings)


Indeed. Please pardon me being nitpick-y and not adding to the conversation.


Just tried it, your right. However, this happened in Visual Studio.


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!


Seems like you need to improve your teaching abilities?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: