Where should class objects be declared?
<p>Should they be declared in the <code>.cpp</code> or <code>.h</code> files?</p>

<p>Example 1:</p>

<pre><code>A.h
#include "B.h"
#include "C.h"

class A
{
    void someFunction();
    B   b;
    C   c;
}
</code></pre>

<p>Example 2:</p>

<pre><code>A.cpp
#include "B.h"
#include "C.h"

A::someFunction()
{
    B   b;
    C   c;
    // Do something with b and c.
}
</code></pre>

<p>Example 3:</p>

<pre><code>A.cpp
#include "B.h"
#include "C.h"

B   b;
C   c;

A::someFunction()
{
    // Do something with b and c.
}
</code></pre>

<p>Should they only be declared in the function that is using them (example 2) or can they be declared at the top of the file under the header includes like in example 3?</p>