attempting to write my own library: identifier "cfg" is undefined

18 Oct 2012

I have started to code my library called cfExstentions that requires the ConfigFile library. I included the ConfigFile.h file into my cfExtensions.cpp file. I tried to initialize the ConfigFile library by coding:

Code that does not work:

//OLD CODE

//cfExtensions.cpp file

cfExtensions::cfExtensions()
{
    ConfigFile cfg;
    LocalFileSystem local("local");

}

void cfExtensions::loadConfigFile() {
    /*
     * Read a configuration file from a mbed.
     */
    if (!cfg.read("/local/settings.cfg")) { //line 45
        printf("Failure to read a configuration file.\n");
    }
}  // End of loadConfigFile

Line 45 is throwing an error: identifier "cfg" is undefined. I'm assuming that I am not calling cfg correctly? What am I not doing?

EDIT: I fixed that issue by initializing the ConfigFile library outside of my constructor.