找出下面程序中的错误,并改正:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class Test
{
public:
string s;
};
main()
{
Test *t=new Test[3];
ofstream output("file",ofstream::binary);
t[0].s="hello";
t[1].s="World";
t[2].s="!";
output.write((char*)t,3*sizeof(Test));
output.close();
delete[] t;
ifstream input("file",ifstream::binary);
Test in[3];
input.read((char*)t,3*sizeof(Test)):
input.close();
cout<<in[0].s<<in[1].s<<in[2].s<<endl;
return 0;
}
//ofstream::binary和ifstream::binary表示已二进制形式进行读写