There is a deeper problem than what you're facing now.
void setPtr(const D &obj) {*m_Ptr = obj};
How do you know if obj is an object created by new? How can you make sure the caller intends that C call delete on its address? What you are doing is bad class design, and there is a much better solution to it that both addresses your current issue and what I'm fussing about.
Make sure first that you have read What is The Rule of Three?
So, how can you make your class design better? Use the Rule of Three! Provide copy (and if available move) constructors and assignment operators. After you have done this, remove setPtr. setPtr is a bad thing. Provide a constructor instead that copies an existing D object. In this way, you insulate the details on how you create what is pointed by m_Ptr.
C(D& d) {m_Ptr = new D(d); };
You should also provide an appropriate copy constructor for D. To use it, instead of
C x;
D* y = new D;
x.setPtr(*D);
you do
C x = D();
// or
C x;
x = C(D());
Do you want C to hold a D depending on some parameters? Maybe they are parameters to D's constructor(s)? You could provide a "named constructor":
class C {
static C createBlah(int x, float y) {
C c = D(x, y);
return c;
}
};
// Using it...
C c = C::createBlah(42, 3.14f);
So now, the users of your class C doesn't have to worry about anything concerning D. Why put the burden on them? Why have them use new when it'll put them in grave danger? Why make the world more miserable?!
There, that's better.
UPDATE: Much better though, make the D object directly as a member, instead of a pointer to it. @Peter's comment pretty much sums up the point.