quick question on fstream

so when i read a file into a class object like this
 
object.read((char*)this, sizeof(object)) 

it starts reading the file into the beginning of the object's address and fills up the whole object but say i had name,address, and number as members of the object could i access each one? like object.getNumber() ?
Yes. If you read data into an object from file, you can access its members just like normal.
1
2
3
4
5
6
7
8
9
10
struct Foo
{
    int bar;
    double lorem;
}
Foo theFoo;
file.read((char*)(&theFoo), sizeof(Foo));
// theFoo can be accessed just like normal
theFoo.bar ++;
theFoo.lorem -= 1234.4321;
Topic archived. No new replies allowed.