【发布时间】:2017-05-12 08:27:19
【问题描述】:
我想做一个图书馆管理系统作为作业
class student
{
char ID_number[30];
char Student_name[30];
public:
void create_student()
{
cout<<"\nEnter The ID Number ";
cin>>ID_number;
cout<<"\n\nEnter The Name of The Student: ";
cin>>Student_name;
cout<<"\n\nStudent Created Successfully"<<endl;
}
void show_student()
{
cout<<"\nID Number: "<<ID_number;
cout<<"\nStudent Name: ";
cin.getline(Student_name,30);
}
我将如何使用动态分配使每个新条目进入一个数组并使用指针来显示某个学生?
我在这方面真的很糟糕,提前谢谢!
【问题讨论】:
-
您可以使用
std::vector<student>。 -
很遗憾,对于这个分配,我只能使用动态分配,我想我可以做到,但不能不列出特定的数组大小
-
vector提供动态分配。你不需要指定它的大小 -
所以写你自己的
vector。 -
抱歉我不是很清楚,我需要使用 new[] 和 delete[] 而不是向量
标签: c++ arrays dynamic allocation