C++ Constructor with delegation -


this question has answer here:

code below:

#include <iostream> #include <cstdio> using namespace std;  typedef char byte; #define buf_size 30  class { public:     a();     ~a(){}     inline const byte* getbuffer() const { return m_pbuf; }     int pop(void); private:     const byte* m_pbuf; };  a::a():m_pbuf() //<---line 19 {     byte* pbuf = new byte[buf_size];     if (pbuf == null)         return;      (int i=0; i<buf_size; i++)     {         pbuf[i] = i;     }      m_pbuf = pbuf; }  int main() {     a;     const byte* pb = a.getbuffer();     if (null != pb)     {         (int = 0; i<buf_size;i++)             printf("%u", pb[i++]);     }      return 0; } 

i trying figure out how many kind of initialization list of c++ constructor provided. , find special 1 above.can please explain line 19. don't know mean. thx in advance.

a::a() calling constructor of a. , operator : initialization list, tells call default constructor on a's private member m_pbuf.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -