0

Can anyone why this code does not work? It says that this operator does not exists or something like that. Please help me

void Account::read_rec()
{
    std::ifstream infile;
    infile.open("record.bank", std::ios::binary);
    if (!infile)
    {
        std::cout << "[Error] File Not Found!" << std::endl;
        return;
    }

    std::cout << "\n***** Data from file *****" << std::endl;

    while (!infile.eof())
    {
        if (infile.read(reinterpret_cast<char*>(this), sizeof(*this) > 0))
        {
            show_data();
        }
    }
    infile.close();
}

1 Answers1

2
if (infile.read(reinterpret_cast<char*>(this), sizeof(*this) > 0))
//                                                          ^   ^
//                                                          A   B

The end of the read function call should be at A, not at B.

You put the bracket in the wrong place.

There is no read(char*, bool) function ;)

Lightness Races in Orbit
  • 358,771
  • 68
  • 593
  • 989