发现一种全新的(我之前从来没见过的)实例化类

class Clog1
{
  public:
    Clog1(int value)
    {
        m_num = value;
    }
    Clog1(char a)
    {
        m_a = a;
    }
    Clog1(const Clog1 &) = delete;
    Clog1(Clog1 &) = delete;
    Clog1 &operator=(Clog1 &) = delete;
    Clog1 &operator=(const Clog1 &) = delete;
    int GetNumber() const
    {
        return m_num;
    }
    void SetNumber(int nNumber)
    {
        m_num = nNumber;
    }

  private:
    std::string m_str;
    int m_num;
    char m_a;
};

int main()
{
    Clog1 mmm = 1;
    Clog1 mma = 'b';
    return 0;
}

这么实例化我从来没见过,通过debug,发现效果跟

    Clog1 mmm(1);
    Clog1 mma('b');

是一样的,都会调用不同的构造函数. 有大神可以帮忙解释一下吗

你可能感兴趣的:(C++知识,c++)