CSimpleIniA - method of wrapper class doesn't read config file value
<p>I wrapped <a href="http://code.jellycan.com/simpleini/" rel="nofollow">CSimpleIniA</a> in a Config class to manage configuration options in a 'config.ini' file.</p>

<p>In the example I provide, <code>sample_size</code> is read in the <code>Config</code> constructor.
When <code>readSampleSize()</code> is called, the value of the configuration file is returned.</p>

<p>By contrast, <code>readInitialPos()</code> should (what I expected) be able to read the <code>config.ini</code> and return the value of <code>inital_pos</code>.  Instead, it returns the default value, the third argument <code>70000</code>.</p>

<p>I don't understand why this second method is not working. </p>

<p>config.hpp</p>

<pre><code>class Config {

private:
    unsigned long int sample_size;  
public:
    unsigned long int readInitialPos ();

    unsigned long int readSampleSize ();

    CSimpleIniA ini;

    Config ();
};
</code></pre>

<p>config.cpp  </p>

<pre><code>#include "../include/config.hpp"

Config::Config () 
{
    CSimpleIniA ini;
    int error_nr = ini.LoadFile("config/config.ini");
    if ( error_nr ) {
        cout &lt;&lt; "Error " &lt;&lt; error_nr &lt;&lt; " opening config.ini file." &lt;&lt; endl;
        exit(3);
    }
    sample_size = ini.GetLongValue("Rock", "sample_size", 50);
}

unsigned long int Config::readInitialPos ()
{
    return ini.GetLongValue("Rock", "initial_pos", 70000);
}   

unsigned long int Config::readSampleSize ()
{
    return sample_size;
}
</code></pre>

<p>caller, rock.cpp</p>

<pre><code>void Rock::readConfig ()
{
    Config config;

    initial_pos = config.readInitialPos ();

    sample_size = config.readSampleSize ();
}
</code></pre>
