I am studying a part of c++ code. I have a head file called efacm.h and a corresponding cpp file called efacm.cpp. The efacm.h file is like this:
#include "al.h"
#include "bl.h"
#include "cl.h"
#include <map>
#include <string>
class efacm
{
public:
efacm();
virtual ~efacm();
void init();
efacm* getcom(std::string acmdstr);
private:
typedef std::map<std::string, efacm*> com_map;
com_map mcom;
al al; // the first al is a class name which is defined in al.h
bl bl; // same as al
cl cl; // same as al
}
Then the efacm.cpp is like:
#include "efacm.h"
efacm::efacm()
: mcom()
, al()
, bl()
, cl()
{} // I DO NOT understand this part!
efacm::~efacm() {}
void efacm::init()
{
mcom["a"] = &al; // I also DO NOT understand this part, why mcom is a vector?
mcom["b"] = &bl;
mcom["c"] = &cl;
}
efacm* efacm::getcom(std::string acmdstr)
{
com_map::iterator pos=mcom.find(acmdstr);
return (pos == mcom.end()) ? NULL : pos->second;
}
As I mentioned in my codes, there are two parts that I do not understand very much. The first one is about
efacm::efacm()
: mcom()
, al()
, bl()
, cl()
{}
The structure looks like class::object():#something here# {object body}. But how to interpret this structure? What do the double colon and the single colon mean here?
The second thing I do not understand is:
void efacm::init()
{
mcom["a"] = &al;
mcom["b"] = &bl;
mcom["c"] = &cl;
}
Here why mcom is a vector? It seems that com_map is not a vector type but mcom is an object of type com_map....
Anyone met such kind of things before?