Tutorial :Segmentation fault in stl map<>


I am not very good at c++ but I have to test a reputation based system. A code fragment is given below which gives me segfault when i run it on ubuntu system. As i wrote in comments two functions "tackleFirstHandInfo()" and "updateReputation()" individually run correctly but when i call one function from the other it crashes. Any help will be greatly appreciated, thanks in advance. the code is below:

"ex.h"    #ifndef _ex_h  #define _ex_h  #include "iostream"  #include <map>  #define FADING 0.9  enum Behaviour {FORWARDING, NOTFORWARDING};    class Rating  {    private:      double reputation;    public:        Rating() { reputation = 5.0; }      Rating(double rep) {reputation = rep;}        ~Rating() {}        double getRep() { return reputation; }        void updateRep(Behaviour behaviour) {          if (behaviour == FORWARDING)              reputation = reputation + 1;              else               reputation = reputation - 1;          }     };    

Next Post »