السلام عليكم
اتمنى انو تساعدوني في هذا الكود
لاني ماعرفت اكملو
ان شاء الله تفيدوني عشان اكمل الكود
#include<iostream>
#include<string>
#include<conio.h>
#include <fstream>
using namespace std;
class Student
{
private:
string studName;
string studMajor;
float studGrade;
public:
int id;
void getStudent()
{
cout<<"Enter student name: ";
cin>>studName;
cout<<"Enter student major: ";
cin>>studMajor;
cout<<"Enter student grade: ";
cin>>studGrade;
cout<<"Enter student ID: ";
cin>>id;
}
void showStudent()
{
cout<<"\tName :"<<studName<<endl;
cout<<"\tMajor :"<<studMajor<<endl;
cout<<"\tGrade :"<<studGrade<<endl;
cout<<"\tID :"<<id<<endl;
}
};
struct Link
{
Student stud;
Link* next;
};
class LinkList
{
private:
Link* head;
public:
LinkList()
{
head=NULL;
}
void insert(Student s);
void show();
void update(Student &s);
void deletestudent();
void save();
void search();
};
void LinkList::insert(Student s)
{
Link* newLink= new Link;
newLink->stud=s;
newLink->next=head;
head=newLink;
}
void LinkList::show()
{
Link*current=head;
cout<<"Student Information List"<<endl;
while(current != NULL)
{
current->stud.showStudent();
current=current->next;
cout<<endl;
}
}
void LinkList::update(&)
{
}
void LinkList::search(int id)
{
Link*current=head;
while(current!= NULL)
{
if(current->id == id)
return * current;
current=current->next;
}
return NULL;
}
void LinkList::deletestudent()
{
Link* current=search();
if(current ==NULL)
cout<<"\nThis student is not in the list\n";
else
{
if(current == head)
{
head=current->next;
delete current;
}
else
{
Link* previous=head;
while(previous !=NULL)
{
if(previous->next==current)
{
previous->next=current->next;
delete current;
}
previous=previous->next;
}
}
}
}
void LinkList::save()
{
ofstream outfile;
ofstream outfile ("Student_Records.dat", ios::app);
}
int main()
{
Student s1;
LinkList LIST1, LIST2;
for(int i=0; i < 2; i++)
{
s1.getStudent();
LIST1.addItem(s1);
}
LIST1.display();
getch();
return 0;
}