Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Did you include the cpp file from the header file?</p> <p><a href="http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13" rel="nofollow noreferrer">http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13</a></p> <blockquote> <p>Notice that foo-impl.cpp #includes a .cpp file, not a .h file. If that's confusing, click your heels twice, think of Kansas, and repeat after me, "I will do it anyway even though it's confusing." You can trust me on this one. But if you don't trust me or are simply curious,</p> </blockquote> <p><strong>EDIT</strong> I got this to compile:</p> <pre><code>////////////////////////////////////////////////////////////////////////// // Foo.cpp - implementation of Foo #include "stdafx.h" template &lt;typename ShadeType&gt; template &lt;typename T&gt; bool IShader&lt;ShadeType&gt;::getProperty(ShaderProperty&lt;T&gt;** outProp){ *outProp = dynamic_cast&lt;ShaderProperty&lt;T&gt;*&gt;( NULL ); return false; } ////////////////////////////////////////////////////////////////////////// // Foo.h template&lt;typename T&gt; class ShaderProperty { }; template &lt;typename ShadeType&gt; class IShader { public: template &lt;typename T&gt; bool getProperty(ShaderProperty&lt;T&gt;** outProp); }; #include "Foo.cpp" ///Main.cpp IShader&lt;someclass&gt; blah; ShaderProperty&lt;someclass2&gt;* prop; blah.getProperty(&amp;prop); </code></pre> <p>So in other words you can't really hide your implementation code from the library users. You either have the code in the header file or include the cpp file WITH the header file.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload