[Solved] Why Can’t Read The File(doesn’t display the data)?


If opening iFile fails then the call to read will also fail and the body of the while loop will never execute. You should check the file opens successfully before using it:

ifstream iFile("shippingAddresses.dat", ios::binary);
if (!iFile)
{
    std::cout << "open failed\n";
    return;
}
while (iFile.read((char *)this, sizeof(*this)))
{
    display_adress();
}

Note that iFile.close(); is unnecessary as the destructor closes the file automatically

solved Why Can’t Read The File(doesn’t display the data)?