I am not sure what I need to google here.
Lets say I have a class like this
1 2 3 4 5 6 7 8 9
Class monster
{
public:
~monster();
private: // private constructors
monster();
monster(int hp, int mp) { m_hp = hp; m_mp = mp;};
int m_hp, m_mp
};
Now I want to to have a txt file like
1 2 3
Orc, 100,0
Elf,50,100
Generic_Tolkienoid 100,100
I want to have another class (which is a friend of monster class) which reads the txt file and makes these objects and puts them in a std::unordered_map, using the name as a key. Which design pattern is this, factory, builder, something else?
Thanks that is cool, I guess by using std::istream the monster class doesn't care if the stream is a file stream or string stream.
I suppose if you used a filestream and loaded the file in the monster class that would work to, but then the class then wouldn't "Do one thing" anymore.