Variable Arguement With Class Reference As 1st Parameter
<p>I have the following code :</p>

<pre><code>#include &lt;cstdarg&gt;
#include &lt;iostream&gt;

using namespace std;

class a {
};

void fun1(a&amp; aa, ...)
{
    va_list argp;
    va_start(argp, aa);
    char *p = 0;
    while ((p = va_arg(argp, char *)) != 0) {
        cout &lt;&lt; p &lt;&lt; endl;
    }
    va_end(argp);
}

void fun2(char *aa, ...)
{
    va_list argp;
    va_start(argp, aa);
    char *p = 0;
    while ((p = va_arg(argp, char *)) != 0) {
        cout &lt;&lt; p &lt;&lt; endl;
    }
    va_end(argp);
}

int main()
{
    cout &lt;&lt; "fun2" &lt;&lt; endl;
    fun2("a", "1", "2", (char *)0);
    cout &lt;&lt; "fun1" &lt;&lt; endl;
    fun1(a(), "1", "2", (char *)0);
    getchar();
}
</code></pre>

<p>Everything works fine with fun2. However, fun1 will just crash.</p>

<p>May I know how can I prevent from crashing, at the same time able to use class reference as 1st parameter.</p>

<p>Currently, it prints :</p>

<pre><code>fun2
1
2
fun1
</code></pre>

<p>then crash.</p>

<p>I wish</p>

<pre><code>fun2
1
2
fun1
1
2
</code></pre>
