class HRException
{
public:
    HRException() :
         m_pMessage("") {}
    virtual ~HRException() {}
    HRException(const char *pMessage) :
         m_pMessage(pMessage) {}
    const char * what() { return m_pMessage; }
private:
    const char *m_pMessage;
};

It's a definition of an exception class I guess. How does the colon and the following "m_pMessage("")" work? Why does it have to be innitialized in this fashion? Thank you very much in advance!

The things between the colon and the curly brace is called the "initialization list". Read this faq on constructors for a good explanation on why this is preferable to assignments inside the body of the constructor.

Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.