C++ Classes versus utility functions
<p>So I may want various functions that operate on a line:</p>

<pre><code>inline float yIntercept(const vec2&amp; ptA, const vec2&amp; ptB, float x);
inline float xIntercept(const vec2&amp; ptA, const vec2&amp; ptB, float y);
inline bool lineIntersection(const vec2&amp; ptA0, const vec2&amp; ptB0, const vec2&amp; ptA1, const vec2&amp; ptB1);
</code></pre>

<p>The functions takes 2 points for each line representing the line.</p>

<p>Or I can write a line class that has those 2 points and various useful line related methods.</p>

<pre><code>struct Line {
    ... stuff

    inline float xIntercept(float y);
    inline float yIntercept(float x);

    inline bool lineIntersection(const Line&amp; other);

    vec2 m_point[2];
};
</code></pre>

<p>One thing I was thinking about is performance of creating an instance of this line class every time I need to call one of these functions just given 2 points.</p>

<p>I may be operating on a point list representing a polygon and don't actually have any line objects instantiated.</p>

<p>At any time I may either call</p>

<pre><code>yIntercept(somePointA, somePointB, 3.0f);
</code></pre>

<p>Or </p>

<pre><code>Line(somePointA, somePointB).yIntercept(3.0f);  //I think this would compile
</code></pre>

<p>I like the idea of having classes for these kinds of things rather than C style functions, but I was wondering if there's some performance penalty of creating an instance of the class like this rather than just passing the points right into a function.  Maybe the compiler does some optimization?</p>
