Printing a triangle of stars I've got a rather long function that will take the size of a triangle print it with stars and give the user the option of whether or not they want stars printed inside the triangle, and the orientation (point up or down).  I was hoping for some general refactoring methodologies I could apply.

Every permutation is possible for inverted/filled, inverted/not filled, etc.  What are some good general methods I can apply here to get some more code reuse?

void Triangle::Print(string direction, string fill)
{
    string starWithSpace = "* ";

    for (int i = leg1 - 1, j = 1; i &gt;= 0; i--, j++, j &lt; i)
    {
        if (direction == "vertical")
        {
            cout &lt;&lt; string(i, ' ');

            if (fill == "yes")
            {
                int repeat = 0;
                while (repeat &lt; j)
                {
                    cout&lt;&lt; starWithSpace;
                    repeat++;
                }
            }
            else if (fill == "no")
            {
                if (j * 2 - 3 &lt; 0)
                {
                    cout &lt;&lt; "*";
                }

                if ( j &gt; 1 &amp;&amp; i &gt;= 1)
                {
                    cout &lt;&lt; "*";
                    cout &lt;&lt; string(((j * 2 - 3) &lt; 0) ? 1 : j * 2 - 3, ' ');
                    cout &lt;&lt; "*";

                }
                if (i == 0)
                {
                    int repeat = 0;
                    while (repeat &lt; leg1)
                    {
                        cout &lt;&lt; starWithSpace;
                        repeat++;
                    }
                }


            }
            cout &lt;&lt; "\n";
        }
        else if (direction == "inverted")
        {
            //print bottom line
            if (j == 1)
            {
                int repeat = 0;
                while (repeat &lt; leg1)
                {
                    cout &lt;&lt; starWithSpace;
                    repeat++;
                }
            }
            cout &lt;&lt; string(j - 1, ' ');
            if (j != 1 &amp;&amp; fill == "yes")
            {
                int repeat = 0;
                while (j &gt;1 &amp;&amp; repeat &lt; i +1)
                {
                    cout &lt;&lt; starWithSpace;
                    repeat++;
                }
            }
            else if (fill == "no" &amp;&amp; j!= 1)
            {
                int skipFactor = i * 2 - 1;
                cout &lt;&lt; "*";
                cout &lt;&lt; string(skipFactor &gt; 0 ? skipFactor: 1, ' ');
                if (i != 0)
                {
                    cout &lt;&lt; "*";
                }
            }
            cout &lt;&lt; "\n";
        }
    }
    cout &lt;&lt; "\n";
}
These comments apply to your question, not your answer.

Using strings as arguments seem unnecessary, it would be better to use bools or enums, that way if you one day change strings (e.g. another language) it does not affect the print function.

void Triangle::Print(Direction direction, bool fill)


There are magic numbers in your code 2,3 etc. try using constants for those
values with descriptive names.

The function is arguably a bit long and has quite a few if-statement levels, better to split into several functions that you can parameterize.  

You may also want to present public functions to the user that do not have all the arguments then leave the original Print protected e.g.

PrintVertical(bool fill)
PrintInverted(bool fill);
...


that may make its use less confusing than keeping track of all possible argument combinations.

You may also want to include the stream to print to as an argument to Print, that way if you can alternatively print to a file instead of cout.