Hello,
I'm a beginner at C++ coding.
I Have two questions.
Please tell me what this code does. thanks. I need to describe the code to someone.
And my second question is, I have a warning with this code!
Thanks in advanced!
And this is my whole source code, just in case.
By the way, is there any other way to write this easier and better?
I'm a beginner at C++ coding.
I Have two questions.
Please tell me what this code does. thanks. I need to describe the code to someone.
Code:
list(int shomareParvaz1,string mabda1,string maghsad1,int gheimat1,list *next1=NULL){
mabda=mabda1;
maghsad=maghsad1;
shomareParvaz=shomareParvaz1;
gheimat=gheimat1;
next=next1;
}
And my second question is, I have a warning with this code!
Code:
if(next != NULL){
prive -> next = next->next; //This line
delete next;
system("cls");
cout << " \n \t Succesfully Removed \n"<<endl;
system("Pause");
system("cls");
}
Thanks in advanced!
And this is my whole source code, just in case.
By the way, is there any other way to write this easier and better?
Code:
#include <iostream>
#include <string>
using namespace std;
struct list{
string mabda;
string maghsad;
int shomareParvaz;
int gheimat;
list(int shomareParvaz1,string mabda1,string maghsad1,int gheimat1,list *next1=NULL){
mabda=mabda1;
maghsad=maghsad1;
shomareParvaz=shomareParvaz1;
gheimat=gheimat1;
next=next1;
}
list *next;
list *prev;
list *temp;
list *tempezafi;
}; list *head;
class flight {
public:
flight(); // constructor
~flight();// destructor
void Add_List(int shomareParvaz, string mabda, string maghsad , int gheimat);
void Delete1(int shomareParvaz);
private:
};
flight::flight(){
head=NULL;
}
flight::~flight(){
list *temp=head;
while ( temp != NULL ){
list *tempezafi=temp;
temp=temp->next;
delete tempezafi;
}
}
void flight::Delete1(int shomareParvaz){
list *prive;
if (head==NULL){
cout<<"List Is Empty"<<endl;
return;}
if (head->shomareParvaz==shomareParvaz){
list *next=head;
head=head->next;
delete next;
system("cls");
cout <<"\n \t Succesfully Removed \n"<<endl;
system("Pause");
system("cls");}
else {
list *next = head;
while (next != NULL && next->shomareParvaz != shomareParvaz){
list *prev = next;
next=next->next;
}
if(next != NULL){
prive -> next = next->next;
delete next;
system("cls");
cout << " \n \t Succesfully Removed \n"<<endl;
system("Pause");
system("cls");
}
}
}