sizeo(结构体)的问题

昨天在写图书管理系统的时候遇到了这样一个问题
结构体定义如下

struct Date{
	int year;
	int month;
	int day;
}

struct book{
	long number;
	char book_name[30];
	char author_name[30];
	double price;
	Date date;
}

book *temp=new book[100];

当使用sizeof时,代码结果如下

cout<< sizeof(temp);//结果为8
cout<<sizeof(temp[0]);//结果为88

猜你喜欢

转载自blog.csdn.net/kking_edc/article/details/85011880