Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

thehurricane

writing classes with static members to a file

This topic is 5630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
yes they will if you type

file.write(reinterpret_cast(&Class::staticMember), sizeof(Class::staticMember));

It's kinda hard to guess how you're using file.write()...

[edited by - civguy on January 19, 2003 4:14:00 PM]

Share this post


Link to post
Share on other sites
Well I was just going to cast the class instance to char and then write it as one binary buffer...I just want to write the entire thing in one go so I don''t have to fuss with individual data members.

Share this post


Link to post
Share on other sites
Try this:

  
#include <iostream>

class A {
public:
static int a;
};

int A::a = 1;

int main() {
std::cout << sizeof(A) << ''\n'' << sizeof(int) << ''\n'';
}

and do your own deductions

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!