title: no matching constructor for initialization of 'vlq'
body: <p>I'm getting <code>no known conversion from 'vlq' to 'uint32_t'</code> (compile log below) when compiling the following code:</p>
  
  <pre><code>// vlq.h
  
  #ifndef __VARIABLE_LENGTH_QUANTITY_H__
  #define __VARIABLE_LENGTH_QUANTITY_H__
  
  #include &lt;memory&gt;
  
  class vlq {
      private:
          std::unique_ptr&lt;uint8_t[]&gt; valueBytes; // pointer to value
          size_t valueLength; // length of value
  
          static size_t encodedLength(uint32_t a);
          static uint8_t* encodeVlq(uint32_t a);  
          static uint32_t decodeVlq(uint8_t* valueBytes, size_t valueLength);
      public:
          vlq(); // defualt constructor
          vlq(uint32_t value);
  
          size_t length() const; // returns number of bytes to store vlq
          uint32_t value() const; // returns encoded value of vlq
  
          vlq operator+ (vlq const &amp;obj);
  };
  
  #endif
  </code></pre>
  
  <pre><code>// vlq.cpp
  
  #include "vlq.h"
  #include &lt;stdexcept&gt; // std::out_of_range
  #include &lt;stdint.h&gt;  // uint8_t, uint32_t
  #include &lt;cmath&gt;     // log2, floor
  
  vlq::vlq() {
      this-&gt;valueBytes.reset();
      this-&gt;valueLength = 0;
  }
  
  vlq::vlq(uint32_t value) {
      size_t valueLength = encodedLength(value);
      uint8_t* valueBytes = encodeVlq(value);
      this-&gt;valueBytes.reset(valueBytes);
      this-&gt;valueLength = valueLength;
  }
  
  // returns required length for passed value
  size_t vlq::encodedLength(uint32_t a) {
      // calculate number of bits required
      size_t numBits = std::floor(std::log2(a)) + 1;
  
      // set length
      size_t length;
      if (numBits % 7 == 0) {
          length = numBits / 7;
      } else {
          length = numBits / 7 + 1;
      }
  
      return length;
  }
  
  // encodes bytes of a vlq
  uint8_t* vlq::encodeVlq(uint32_t a) {
      size_t length = encodedLength(a);
  
      uint8_t *formattedVlqBytes = new uint8_t[length];
  
      // turn a into 7 bit chunks
      int chunkOffset;
      for (int i = 0; i &lt; length; i++) {
          chunkOffset = (length - i - 1) * 7;
  
          formattedVlqBytes[i] = (a &amp; (0x7F &lt;&lt; chunkOffset)) &gt;&gt; chunkOffset;
  
          // set bit if this isn't the last bit
          if (i != length - 1) {
              formattedVlqBytes[i] |= 0x80;
          }
      }
  
      return formattedVlqBytes;
  }
  
  // decodes bytes of a vlq
  uint32_t vlq::decodeVlq(uint8_t* valueBytes, size_t valueLength) {
      size_t numBits = valueLength * 7;
  
      uint32_t decodedVlq = 0x0;
  
      size_t byteOffset, bitOffset;
      for (size_t i = 0; i &lt; numBits; i++) {
          byteOffset = i / 7;
          bitOffset = 6 - (i % 7);
  
          decodedVlq |= valueBytes[byteOffset] &amp; (0x1 &lt;&lt; bitOffset) &lt;&lt; (valueLength - byteOffset - 1) * 7;
      }
  
      return decodedVlq;
  }
  
  // returns encoded value of vlq
  uint32_t vlq::value() const {
      return decodeVlq(this-&gt;valueBytes.get(), this-&gt;valueLength);
  }
  
  vlq vlq::operator+(vlq const &amp;obj) {
      uint32_t sum = this-&gt;value() + obj.value();
  
      return vlq(sum);
  }
  </code></pre>
  
  <pre><code>// compiler output
  
  vlq.cpp:81:9: error: no matching constructor for initialization of 'vlq'
          return vlq(sum);
                 ^~~~~~~~
  ./vlq.h:6:7: note: candidate constructor (the implicit copy constructor) not viable: expects an l-value for 1st argument
  class vlq {
        ^
  vlq.cpp:11:6: note: candidate constructor not viable: no known conversion from 'vlq' to 'uint32_t' (aka 'unsigned int') for 1st argument
  vlq::vlq(uint32_t value) {
       ^
  vlq.cpp:6:6: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
  vlq::vlq() {
       ^
  1 error generated.
  </code></pre>
  
  <p>Why am I getting <code>no known conversion from 'vlq' to 'uint32_t'</code> when passing a <code>uint32_t</code>?</p>