Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ code snippet for a new baby greeting card

Tags:

c++

A friend of mine sent me this code snippet to celebrate his new baby birth:

void new_baby_name() { father_surname++; }

The snippet is from his point of view, he is the father and the new baby get the surname from him.

I answered with this:

class father_name {};
class mother_name {};
class new_baby_name: public father_name, public mother_name {};

But I'm not fully satisfied of my answer...

like image 408
Alessandro Jacopson Avatar asked Mar 06 '10 08:03

Alessandro Jacopson


3 Answers

The correct reply is:

Sleep(0);
like image 183
Jason Williams Avatar answered Nov 20 '22 10:11

Jason Williams


class baby
{
public:
    vector<gene> genes;
    baby(baby* logical_father, baby* biological_mother, baby* other)
    {

        int i;
        if (other == null)
        {
            for (i = 0; i < logical_father->genes.size())
            {
                if (rand() > 0.5)
                {
                    genes.push_back(logical_father->genes[i]);
                }
                else
                {
                    genes.push_back(biological_mother->genes[i]);
                }
            }
        }
        else
        {
            for (i = 0; i < other->genes.size())
            {
                if (rand() > 0.5)
                {
                    genes.push_back(other->genes[i]);
                }
                else
                {
                    genes.push_back(biological_mother->genes[i]);
                }
            }
        }
    }
}

There are, of course, other methods for constructing a baby.

like image 21
Simon Avatar answered Nov 20 '22 10:11

Simon


destroy Sanity();

May not run, may stack overflow. I am not good at c.

like image 1
glasnt Avatar answered Nov 20 '22 09:11

glasnt