Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>#include &lt;iostream&gt; #include &lt;sstream&gt; double strToDouble(std::string const &amp;numberString) { std::istringstream inStream(numberString); double doubleValue; std::cout &lt;&lt; doubleValue &lt;&lt; '\n'; inStream &gt;&gt; doubleValue; if(!(inStream &amp;&amp; (inStream &gt;&gt; std::ws).eof())) { return 0.0; } return doubleValue; }; int main() { std::cout &lt;&lt; strToDouble("0.1") &lt;&lt; '\n'; return 0; } </code></pre> <p>The above code gives me the following output:<br> -2.36907e-39<br> 0.1</p> <p>Are you by chance checking the value of doubleValue before returning?</p> <hr> <pre><code>Cluster::Cluster(string latString, string lngString) { // mark our vectors vector&lt;string&gt; latStoreString; vector&lt;string&gt; lngStoreString; // Explode our input strings. explode(",", latString, latStoreString); explode(",", lngString, lngStoreString); for( int i = 0; i &lt; latStoreString.size(); i++) { // Grab the latitude and store it. string tempLat = latStoreString[i]; std::cout &lt;&lt; "tempLat=" &lt;&lt; tempLat &lt;&lt; '\n'; double latDouble = strToDouble(tempLat); std::cout &lt;&lt; "latDouble=" &lt;&lt; latDouble &lt;&lt; '\n'; latStore.push_back( strToDouble(tempLat) ); // Grab the longitude and store it. string tempLng = lngStoreString[i]; lngStore.push_back( strToDouble(tempLng) ); } } int main (int argc, char * const argv[]) { Cluster *rect = new Cluster("0.1,0.4","0.1,0.4"); return 0; } </code></pre> <p>Output:<br> tempLat=0.1<br> latDouble=0.1<br> tempLat=0.4<br> latDouble=0.4 </p> <p>Can you run the code with these modifications (you weren't using the int parameter in the ctor, so I just removed it). I also ran your code using valgrind without errors (only memory leaks).</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.
 

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