As others have said, it is preferable to avoid this situation by using smart pointers or by deleting an object at the same level that was created ... or not using pointers at all.
At the same time, I would not say that this is a bad design for transferring ownership of an object if you make it obvious to ClassA users in the documentation. I faced a similar situation when writing functions that take a pointer to an object and copy-construct it for their own use. Where necessary, I try to annotate these functions with the help of "parameter copy semantics" or something that tells the caller: "After I return, you can do what you want after my ... U I have my own copy. "
If you use raw pointers, I would consider it important to establish these types of call contracts.
Nathan pitman
source share