Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ working with smart pointers
    primarykey
    data
    text
    <p>In my code, I have function prototype </p> <pre><code>void AddBenchNode(ref_ptr&lt;Group&gt; root ,ref_ptr&lt;Node&gt; benches, bool setAttitude = false, float scale_x =.15, float scale_y =15, float scale_z = 15, int position_x = 250, int position_y = 100, int position_z =0 ); </code></pre> <p>where ref_ptr is a smart pointer.</p> <p>In my main function, I define 2 smartpointers of type ref_ptr and ref_ptr and pass them to a call to my function, AddBenchNode. </p> <pre><code>ref_ptr&lt;Group&gt; root = new Group(); ref_ptr&lt;Node&gt; benches = readNodeFile("Models/test.ive"); AddBenchNode(root, benches, true); </code></pre> <p>When the call executes, nothing happens. As in no changes are made to the root pointer. What I want to know is if I am making this call correctly as I have it? Or do I have to re-define my function to take pointers to these smartpointers? </p> <p>Now I did try passing by reference</p> <pre><code>void AddBenchNode(osg::ref_ptr&lt;osg::Group&gt;&amp; root ,osg::ref_ptr&lt;osg::Node&gt;&amp; benches, bool setAttitude = false, float scale_x =.15, float scale_y =15, float scale_z = 15, int position_x = 250, int position_y = 100, int position_z =0 ); </code></pre> <p>That resulted in some linker errors. </p> <p><strong>Error 2 error LNK2001: unresolved external symbol "void __cdecl AddBenchNode(class osg::ref_ptr &amp;,class osg::ref_ptr &amp;,bool,float,float,float,int,int,int)" (?AddBenchNode@@YAXAAV?$ref_ptr@VGroup@osg@@@osg@@AAV?$ref_ptr@VNode@osg@@@2@_NMMMHHH@Z) Error 3 error LNK1120: 1 unresolved externals</strong> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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