Initialize in constructor shared_ptr to map with string and weak_ptr?

I have a class Account and two child classes GiroAccount and BusinessAccount.In Account class I want to implement constructors, it look like this:

1
2
3
  Account :: Account( int nr, int balance, int limit, map<string, weak_ptr<Person>> persons ) : nr{nr}, balance{balance}, limit{limit}, persons{persons}{}

GiroAccount :: GiroAccount(int nr, int balance, int limit, shared_ptr<Person> p, double fee_factor ) : //??? 
I assume this is what you wanted?

1
2
3
4
5
6
7
8
#include <string>
#include <map>
#include <memory>
class GiroAccount : public Account
{
    GiroAccount(int nr, int balance, int limit, std::shared_ptr<Person> p, double fee_factor ) 
            : Account(nr, balance, limit, {{std::to_string(fee_factor), p}}) {}
};
Topic archived. No new replies allowed.