xxx will be initialized after

8658阅读 0评论2012-03-28 dmastery
分类:C/C++

作为一个有强迫症的人,实在是受不了 warning 的存在
这个warning是由于初始化顺序引起的, 

点击(此处)折叠或打开

  1. // 会出现warning 的代码!
  2. class cInit
  3. {
  4. public:
  5.     cInit(std::string str, int a) : str_(str), a_(a)
  6.     { }

  7. private:
  8.     int a_;
  9.     std::string str_;
  10. };

点击(此处)折叠或打开

  1. // OK
  2. class cInit
  3. {
  4. public:
  5.     cInit(std::string str, int a) : str_(str), a_(a)
  6.     { }

  7. private:
  8.     std::string str_;
  9.     int a_;
  10. };



上一篇:ora-02030 and create view failed
下一篇:gsoap USCORE出现原因及解决办法