gpt4 book ai didi

c++ - 退出程序MFC后保留变量值

转载 作者:行者123 更新时间:2023-11-28 03:05:00 24 4
gpt4 key购买 nike

我在我的 MFC 程序中用 CStrings 创建了一个结构。我还做了一个指针,这样我就可以将它发送到我的 CMyDoc 类。如何保存变量,使程序退出后该值保留?

最佳答案

假设您的 CMyDoc 是从 CDocument 继承的,您需要重写 Serialize 方法。此处提供更多信息:

Serializing Data to and from Files

The MFC Application Wizard places a skeletal override of the CDocument member function Serialize in the document class it creates for you. After you have implemented your application's member variables, you can fill in your Serialize override with code that sends the data to an "archive object" connected to a file. A CArchive object is similar to the cin and cout input/output objects from the C++ iostream library. However, CArchive writes and reads binary format, not formatted text.

CDocument Class

Override the CObject::Serialize member function in your document class to write and read the document's data to and from disk.

关于c++ - 退出程序MFC后保留变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19948410/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com