0

I have this two maps in a class: (Map is a class I have built almost like the std::map but with only a one-directional iterator.)

Map<Id,shared_ptr<Fan>> fans;

Map<int,shared_ptr<FanBookPost>> posts;

I have a lot of memory leak and I understand its because of a broken use of shared_ptr can I change it to another type of pointer that I don't have to free its location manually? I don't need to point at one element by two pointers.

Some code from my project:

void FanBookServer::connect(shared_ptr<Fan> fan) {
    if(fan==NULL) {
        throw MtmBadParams();
    }
    fan->status=connected;
    fans.insert(fan->id, fan);
}
nandhp
  • 4,680
  • 2
  • 30
  • 42
user3036061
  • 87
  • 2
  • 9

0 Answers0