I think adding compress() / uncompress() functions would be elegant, and providing the constructor you wrote as syntactic sugar is already the best practice. At least that is how I usually do it:

Qt Code:
  1. class myclass
  2. {
  3. public:
  4. MyClass();
  5. ~MyClass():
  6.  
  7. MyClass(CompressedData& data);
  8.  
  9. compress(CompressedData& data) const; // or serialize() ... or save() ...
  10. uncompress(CompressedData& data);
  11.  
  12. // ...
  13. };
To copy to clipboard, switch view to plain text mode