Results 1 to 4 of 4

Thread: Saving a class to disk and then reading it back in

  1. #1

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037

    Saving a class to disk and then reading it back in

    I am trying to save my program settings to disk but I cannot cast the data (a char*) to my class called Settings. This is done easily in C#, how do I do it in C++?

  2. #2

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    I have to stop thinking with a C# mentality. I wasn't casting it to a pointer!

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Direct serialization of class objects in C++ is highly complex and best avoided. Use alternative serialization. Save the data from the Settings class to a .ini, .properties or .xml, anything.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    Is this ok?

    Code:
    class Settings
    {
    	public:
    	BYTE brStyle0_1_2;
    	BYTE spAssignOp0_1_2;
    	bool spFuncsAndStructs;
    	bool spSemiColins;
    	bool spOperators;
    	bool replNullWZero;
    	bool spCommas;
    	Settings()
    	{
    		this->brStyle0_1_2= 2;
    		this->spAssignOp0_1_2= 1;
    		this->spFuncsAndStructs= 0;
    		this->spSemiColins= 1;
    		this->spOperators= 1;
    		this->spCommas= 1;
    		this->replNullWZero= 1;
    	}
    };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width