Hi guys, i try to write my data into a binary file, but j have some problem in it . I dont know what happening inside..
//////////////////////Here is my code/////////////////////////////
class Person{
char Name[50];
char Address[10;
bool sex;
short age;
public:
Person();
Person(char* name, char *address, bool sex, short age);
const char* GetName() const;
const char* GetAddress() const;
};
ostream& operator<<(ostream& out, const Person&p)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(p));
return out;
}
istream& operator>>(istream& in, Person &p)
{
in.read(reinterpret_cast<char*>(&p), sizeof(p));
return in;
}
//Person detail reading and writing is performed well
//////////////////AccountProperty Class///////////////////////////////
class Account_Property{
int account_number;
double amount;
bool account_type;
Person p;
public:
Account_Property();
Account_Property(Person p, int ac_num, bool ac_type, double amt);
int GetAccountNumber()const;
double GetAmount()const;
};
ostream &operator<<(ostream &out, const Account_Property &ap)
{
out.write(reinterpret_cast<const char*>(&ap), sizeof(ap));
return out;
}
istream& operator>>(istream &in, Account_Property &ap)
{
in.read(reinterpret_cast<char*>(&ap), sizeof(ap));
return in;
}
//Account_Property readin writing is not performed perfectly ,whats the reason some one explain me.....
Thanks in Advance