How to convert object to int?
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.
精彩评论