skip to main | skip to sidebar

Tuesday, June 1, 2010

Surprise! C++ version

// Could you explain why this happens:

#include <iostream>

int surprise()
{
    int j = 0;
    if (true) int j = 7;
    return j;
}

int main()
{
    std::cout << "surprise = " << surprise() << std::endl;
    return 0;
}

Posted by David Chaves at 9:38 AM

0 comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

blog.chaves.ca

// David Chaves

About Me

My Photo
David Chaves
http://david.chaves.ca
View my complete profile

Blog Archive

  • ▼  2010 (7)
    • ►  December (5)
      • Máquina: Carretillo para Jardín
      • Aprender a Pensar
      • Crisis... ¿Cual Crisis?
      • ¿Quién entiende a las mujeres?
      • Top 10 tips for living a life of dignity
    • ▼  June (1)
      • Surprise! C++ version
    • ►  March (1)
      • Financial Chaos
  • ►  2009 (6)
    • ►  July (1)
      • Ram Shift
    • ►  April (1)
      • The Voca People
    • ►  March (2)
      • Innovative methodology: Rubber Duck method of debu...
      • Systems thinking, Passion, and Clear communication...
    • ►  February (2)
      • I will buy your monkeys
      • Nassim Nicholas Taleb's Top Life Tips
  • ►  2008 (5)
    • ►  September (1)
      • USA Evolution
    • ►  August (2)
      • How to write a short article
      • Say it simple!
    • ►  July (2)
      • Using Google Earth...
      • How Canada's Health Care System Works

GrandCentral