开发者

How to convert object to int?

开发者 https://www.devze.com 2023-03-03 13:01 出处:网络
I have a class named object that have some instan开发者_开发百科ce vars. I want to save it to file. How can I cast it to type(e.g. int) that can be written to file?If I understand correcty you want to

I have a class named object that have some instan开发者_开发百科ce vars. I want to save it to file. How can I cast it to type(e.g. int) that can be written to file?


If I understand correcty you want to save an object to hard drive? That is called serialization. You might want to check the boost library for that.


If it has several data members - you cannot do this (without using some external (3rd party) lib - that's an addition). Instead, write your own function for storing your object into a file, and one for reading from it.

0

精彩评论

暂无评论...
验证码 换一张
取 消