user28222: My sketch looks somehow like this:
ClassA classA;

void setup() {
    Serial.begin(9600);

    classA = ClassA();
    Serial.println("Bar")

    ...
}

void loop() {
    classA.functionFoo();
}

The constructor of ClassA however calls some internal methods that perform a Serial.println().
My problem is, that the first (implicit) call of the constructor of ClassA comes in the first line of the sketch with
ClassA classA;

This is before the Serial interface has been initialized (with Serial.begin(9600)). Therefore the Serial.monitor cannot interpret the first messages coming from the serial interface.
How can I either suppress any Serial.writes before the setup function or otherwise make sure that the Serial interface is initialized before the setup function?

user28551: In order to be sure that your classA object doesn't use the Serial.println() function before the baudrate is defined, it is necessary to add functions in your class ClassA and to inform from setup() your classA object.
The simplest way is to add:

a boolean bool bSerialReadyto keep the status of the Serial object,
in all ClassA constructors, initialize that bSerialReady = false;,
add a function void SetSerialReady() to switch the status bSerialReady = true;. The function should be called in the setup()function just after Serial.begin(9600);,
and in all functions of ClassA, add a if-condition if (bSerialReady) before calling the Serial.println().

Your class ClassA will become:
class ClassA
{
private:
    bool bSerialReady;
public:
    ClassA() {
        // ...
        // Initialize bSerialReady
        bSerialReady = false;
    };
    void SetSerialReady() {
        bSerialReady = true;
    };
};

Your setup() function becomes:
void setup() {
    Serial.begin(9600);
    classA.SetSerialReady();
    ...
}

And in functions of ClassA, it looks like:
if (bSerialReady) {
    Serial.println("Bar");
}


user4143: You can make your current object a pointer so it isn't instantiated:
ClassA *classA;

Then create an object with new:
classA = new ClassA();

The constructor is then only called when the object is made.
Note that you will have to change your accessors to ->:
classA->myFunction();


28222: <p>My sketch looks somehow like this:</p>

<pre><code>ClassA classA;

void setup() {
    Serial.begin(9600);

    classA = ClassA();
    Serial.println("Bar")

    ...
}

void loop() {
    classA.functionFoo();
}
</code></pre>

<p>The constructor of <code>ClassA</code> however calls some internal methods that perform a <code>Serial.println()</code>.</p>

<p>My problem is, that the first (implicit) call of the constructor of <code>ClassA</code> comes in the first line of the sketch with</p>

<pre><code>ClassA classA;
</code></pre>

<p>This is before the Serial interface has been initialized (with <code>Serial.begin(9600)</code>). Therefore the Serial.monitor cannot interpret the first messages coming from the serial interface.</p>

<p>How can I either suppress any Serial.writes before the setup function or otherwise make sure that the Serial interface is initialized before the setup function?</p>
 28551: <p>In order to be sure that your <code>classA</code> object doesn't use the <code>Serial.println()</code> function before the baudrate is defined, it is necessary to add functions in your <code>class ClassA</code> and to inform from <code>setup()</code> your <code>classA</code> object.</p>

<p>The simplest way is to add:</p>

<ol>
<li>a boolean <code>bool bSerialReady</code>to keep the status of the Serial object,</li>
<li>in all <code>ClassA</code> constructors, initialize that <code>bSerialReady = false;</code>,</li>
<li>add a function <code>void SetSerialReady()</code> to switch the status <code>bSerialReady = true;</code>. The function should be called in the <code>setup()</code>function just after <code>Serial.begin(9600);</code>,</li>
<li>and in all functions of <code>ClassA</code>, add a if-condition <code>if (bSerialReady)</code> before calling the <code>Serial.println()</code>.</li>
</ol>

<p>Your <code>class ClassA</code> will become:</p>

<pre><code>class ClassA
{
private:
    bool bSerialReady;
public:
    ClassA() {
        // ...
        // Initialize bSerialReady
        bSerialReady = false;
    };
    void SetSerialReady() {
        bSerialReady = true;
    };
};
</code></pre>

<p>Your <code>setup()</code> function becomes:</p>

<pre><code>void setup() {
    Serial.begin(9600);
    classA.SetSerialReady();
    ...
}
</code></pre>

<p>And in functions of <code>ClassA</code>, it looks like:</p>

<pre><code>if (bSerialReady) {
    Serial.println("Bar");
}
</code></pre>
 4143: <p>You can make your current object a pointer so it isn't instantiated:</p>

<pre><code>ClassA *classA;
</code></pre>

<p>Then create an object with new:</p>

<pre><code>classA = new ClassA();
</code></pre>

<p>The constructor is then only called when the object is made.</p>

<p>Note that you will have to change your accessors to <code>-&gt;</code>:</p>

<pre><code>classA-&gt;myFunction();
</code></pre>
