【发布时间】:2010-05-22 18:08:12
【问题描述】:
以下函数将结构写入文件。
#define PAGESIZE sizeof(BTPAGE)
#define HEADERSIZE 2L
int btwrite(short rrn, BTPAGE *page_ptr)
{
long addr;
addr = (long) rrn * (long) PAGESIZE + HEADERSIZE;
lseek(btfd, addr, 0);
return (write(btfd, page_ptr, PAGESIZE));
}
下面是结构体
typedef struct {
short keycount; /* number of keys in page */
int key[MAXKEYS]; /* the actual keys */
int value[MAXKEYS]; /* the actual values */
short child[MAXKEYS+1]; /* ptrs to rrns of descendants */
} BTPAGE;
如果我将结构更改为类会发生什么,它仍然可以正常工作吗?
如果我添加类函数,它在磁盘上占用的大小会增加吗?
【问题讨论】:
标签: c++ class file-io struct g++