Some Code Analyze

Joined
Jul 3, 2012
Messages
3
Reaction score
0
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.
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");
	}
	}



		 
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top