本文整理汇总了C++中Database::Display方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::Display方法的具体用法?C++ Database::Display怎么用?C++ Database::Display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database::Display方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Database database;
Student std_data;
int choice = 1;
char filename[Student::NAME_LEN];
while(choice != 5)
{
database.Instruction();
scanf("%d",&choice);
switch(choice)
{
case 1: /* Add a reocrd */
int age, score;
char gender, name[Student::NAME_LEN];
getchar();
printf("\nPlease enter student's name : ");
gets(name);
std_data.SetName(name);
printf("Please enter student's gender(M/F) : ");
scanf("%c", &gender);
std_data.SetGender(gender);
printf("Please enter student's age : ");
scanf("%d", &age);
std_data.SetAge(age);
for(int i = 0 ; i < Student::SCORE_NUM ; i++)
{
printf("Please enter student's %dth score : ", i + 1);
scanf("%d", &score);
std_data.SetScore(i, score);
}
database.AddData(std_data);
break;
case 2: /* Show all records */
database.Display();
break;
case 3: /* Output record to a text file */
getchar();
printf("\nPlease enter input file name : ");
gets(filename);
database.WriteToFile(filename);
break;
case 4: /* Read in records from a text file */
getchar();
printf("\nPlease enter output file name : ");
gets(filename);
database.ReadFromFile(filename);
break;
default:
break;
}
}
return 0;
}