Search Results

Search found 1 results on 1 pages for 'user308012'.

Page 1/1 | 1 

  • Segmentation Fault when trying to push a string to the back of a list.

    - by user308012
    I am trying to write a logger class for my C++ calculator, but I'm experiencing a problem while trying to push a string into a list. I have tried researching this issue and have found some information on this, but nothing that seems to help with my problem. I am using a rather basic C++ compiler, with little debugging utilities and I've not used C++ in quite some time (even then it was only a small amount). My code: #ifndef _LOGGER_H_ #define _LOGGER_H_ #include <iostream> #include <list> #include <string> using std::cout; using std::cin; using std::endl; using std::list; using std::string; class Logger { private: list<string> *mEntries; public: Logger() { // Initialize the entries list mEntries = new list<string>(); } ~Logger() { // Release the list mEntries->clear(); delete mEntries; } // Public Methods void WriteEntry(string entry) { // *** BELOW LINE IS MARKED WITH THE ERROR *** mEntries->push_back(string(entryData)); } void DisplayEntries() { cout << endl << "**********************" << endl << "* Logger Entries *" << endl << "**********************" << endl << endl; for(list<string>::iterator it = mEntries->begin(); it != mEntries->end(); it++) { cout << *it << endl; } } }; #endif I am calling the WriteEntry method by simply passing in a string, like so: mLogger->WriteEntry("Testing"); Any advice on this would be greatly appreciated.

    Read the article

1