How to forward declare a custom constructor?
<p>Note: I have found the issue with how my Xcode was compiling the below and it appears unrelated to the topic discussed herein. When I have more details I will provide them here.</p>

<p>I recommend voting to close my question as "too localized" since it was an Xcode problem, unrelated to the c++ code itself. Many thanks for the help all the same as I did learn from the answers. </p>

<p>The below question (now answered and resolved) was caused by a confusing exclusion of a file from the Xcode target, thus there were no compiler errors even though the file had problems.</p>

<hr>

<p>I have a pure virtual interface and want to define its factory method, which returns a subclass of this interface. This works fine:</p>

<pre><code>struct MyVirt{
...all virtual stuff
};

class SubVirt; //forward declaration allows factory:
MyVirt*CreateClass(){
return new SubVirt;
}
</code></pre>

<p>Update: Some of the comments say that forward declare is not enough to achieve the above, but that's not correct. You can accomplish the above fine without the full definition of the <code>SubVirt</code> class.</p>

<p>Now, what I want to do is have a custom constructor that takes arguments. As such:</p>

<pre><code>MyVirt*CreateClass(){
return new SubVirt(arg 1, etc);
}
</code></pre>

<p>The problem is that a <code>class</code> forward declaration is no longer sufficient. It needs to see the class definition or its header. This means I can either move the factory method to the file where <code>SubVirt</code> is defined, or I have to include that file in the above file, which creates a circular dependency.</p>

<p>Is there a way to forward declare the custom constructor instead? That would make it all much simpler.</p>
