Consider the following code.
请考虑以下代码。
struct MyImage
{
MyImage(const int handle);
MyImage(const CString& filePath);
virtual ~MyImage();
void Process();
void SaveAs(const CString& filePath);
// No copying!
MyImage(const MyImage& other) = delete;
MyImage& operator=(const MyImage& other) = delete;
}
void ProcessImageFile(const CString& inFilePath, const CString& outFilePath)
{
MyImage& image = MyImage(-1); // initialized with invalid handle
if (DecryptionRequired())
{
const CString tempFilePath = ::GetTempFileName();
Decrypt(inFilePath, tempFilePath);
image = MyImage(tempFilePath);
_tremove(tempFilePath);
}
else
{
image = MyImage(inFilePath);
}
image.Process();
image.SaveAs(outFilePath);
}
struc