I'm familiar with the way Qt uses D-pointers for managing data. How do I do this in my code?
I tried this method:
1) move all data into a struct 2) add a QAtomicInt to the struct 3) implement a = operator and change my constructor/deconstructor to check-up on the reference count.
The issue is, when I go to do a shallow copy of the object, I get an error about QObject declaring = as private. How then do I accomplish this?
Here's an example of my copy operator:
HttpRequest & HttpRequest::operator=(const HttpRequest &other)
{
other.d->ref.ref();
if (!d->ref.deref())
delete d;
d = other.d;
return *this;
}
Am I going about this the wrong way?