64,282
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <windows.h>
#include <assert.h>
class A
{
private:
int m_low;
int m_high;
public:
A()
{
m_low = 0;
m_high = 0;
}
A(int low, int high)
{
m_low = low;
m_high = high;
}
void Print()
{
printf("%d %d\n", m_low, m_high);
}
};
int main()
{
A aa(30, 20);
FILE *fpOut = fopen("a.txt", "w");
assert(fpOut!=NULL);
fwrite(&aa, 8, 1, fpOut);
fclose(fpOut);
FILE *fpIn = fopen("a.txt", "r");
assert(fpIn!=NULL);
A bb;
fread(&bb, 8, 1, fpIn);
fclose(fpIn);
bb.Print();
return 0;
}