简体   繁体   中英

How to convert object to int?

I have a class named object that have some instance vars. I want to save it to file. How can I cast it to type(eg 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM