OOP and Filing Related Question

Nov 22, 2013 at 5:22am
CAN WE READ AND WRITE AN OBJECT OF CLASS OF SIZE 10 MB???
Nov 22, 2013 at 5:35am
The answer is yes.
Nov 22, 2013 at 6:32am
can you kindly explain your answer
Nov 22, 2013 at 6:58am
How much do you know?
Nov 22, 2013 at 7:14am
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cmath>
#include <conio.h>
using namespace std;

struct node3{
node3(){
nextContent = NULL;
for (int i = 0; i<1020; i++)
content[i] = '\0';
}

char content[1020];
node3* nextContent;
};
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
struct node1{
node1(){
for (int i = 0; i<496; i++)
fileName[i] = '\0';
}

char fileName[496];
node3* contentAdress;
};
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
struct node2{
node3* contentAddress;
};

class fileSystem{
private:
node1 obj1[2097];
node2 obj2[8192];
node3 obj3[8192];
};


When I write
fileSystem* obj = new fileSystem();
ofstream os("file.dat", ios::binary);
os.write( reinterpret_cast<char*>(*obj), sizeof(*obj) );

in main.

I get:
error C2440: 'reinterpret_cast' : cannot convert from 'fileSystem' to 'char *'
1> Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_cast
Nov 22, 2013 at 7:19am
Topic archived. No new replies allowed.