A lazy software engineer was recently browsing over the source code in his company's code repository (Because he was bored of reading puzzles on Puzzling.SE) when he found the following source code:

class Egg {
    Egg() : hatched_{ false } { }
    bool hatched() { return hatched_; }
    Egg(bool hatched) : hatched_{ hatched } { }
    bool hatched_;

struct Chicken : public Egg {
    Chicken() : Egg{ true } { } 

void count(Egg* (&eggs)[5]) {
    for (const auto& egg : eggs)
        if (!egg->hatched())
            throw "Exception";

void hatch(Egg*& egg) {
    delete egg;
    egg = new Chicken;

int main() {
    Egg* eggs[5];

    for (auto& egg : eggs)
        egg = new Egg;


    // count(eggs);


    // count(eggs);



    for (const auto& egg : eggs) // Resources cleaned up!
        delete egg;

Looking over the source code, the lazy engineer couldn't find anything meaningful. Running the code produced no output. The only (shocking) thing he noticed was the memory leak in the case of the thrown exception (Someone needs to teach this guy RAII)

What phrase does the source code above represent?

Very Big Hint:

The phrase is a (fairly common) idiom.

  • $\begingroup$ Why was this downvoted? $\endgroup$ Commented Mar 22, 2018 at 22:38
  • $\begingroup$ The downvotes are likely because it's easy. You use "count", "chicken", and "hatch" directly in the code, and there's only one common phrase using all of those. It doesn't require any knowledge of the code - in fact, I got it just from a glance at the snippet posted in The Sphinx's Lair (our site chat) $\endgroup$
    – Deusovi
    Commented Mar 22, 2018 at 23:24
  • $\begingroup$ @Deusovi Sorry, I'm new to this website, I didn't know the level of difficulty mattered that much. Will keep that in mind with future questions. $\endgroup$ Commented Mar 22, 2018 at 23:34
  • $\begingroup$ It's not necessarily the difficulty level that's important. Easy puzzles and hard puzzles can both be well-received. But your puzzle should be interesting - and something that can be figured out at a glance likely won't be considered interesting. $\endgroup$
    – Deusovi
    Commented Mar 22, 2018 at 23:35
  • 2
    $\begingroup$ (Don't forget - the puzzle should be interesting, not just the story surrounding it.) Good luck with your next puzzle! $\endgroup$
    – Deusovi
    Commented Mar 22, 2018 at 23:37

1 Answer 1


The phrase is:

Don't count your chickens before they're hatched


The hatch function turns an Egg into a Chicken. The user has an array of eggs but hatches all of them before counting the chickens. It looks like he tried counting them before they were hatched (resulting in the exception which prevented him from doing that) so he commented those out. Finally he was able to count them after they had all been hatched.

  • $\begingroup$ It was that easy? -_- I need to think of something harder... $\endgroup$ Commented Mar 22, 2018 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.