Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're confused between a reference and a pointer I think. The function takes references like vector &amp;headers, string &amp;host_, etc. Your class stores pointers which are not the same thing.</p> <p>If you pass a variable into a function normally, (no * or &amp; in the signature) then you create a copy of the thing you pass in. This is "pass-by-copy". If you pass in a pointer (*), you're passing something that points to the memory address of the variable that you want to use. Technically you're passing the pointer by copy, but it points to the same thing so you're okay. If you pass in a reference (&amp;), then you're aliasing the variable from the scope where the function is called. You're saying "I want to treat this variable like I would in pass by copy, except I want the changes to apply to the one originally passed into the function as well from the outer scope".</p> <p>So, your class can contain normal members instead:</p> <pre><code>private: string host; string port; string url; ostream out; vector&lt;string&gt; header; unsigned int timeout; </code></pre> <p>That way you can pass them directly to the function without an issue. They will also be default constructed in this case so you don't need to use "new" or do anything. In fact, you wouldn't even need to write a constructor.</p> <p>Mind, you probably need an accessor function to let you modify all of these since you made them private, or you'll need to make your constructor take parameters so you can give the data members useful values before using the structure.</p> <p><strong>PS:</strong> You want to use std::ofstream instead for your output :) Check out the following example at the link below:</p> <p><a href="http://www.cplusplus.com/doc/tutorial/files/" rel="nofollow">http://www.cplusplus.com/doc/tutorial/files/</a></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.
    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