Add to Linked List Problem!

hi
i have problem with add function in flight class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <string>
using namespace std;
class flight {
public:
	flight(); // constructor
	~flight();// destructor
	void Add_List();
	void Print_List();
	void Search_List();
	void Delete_List();
private:
	string mabda;
	string maghsad;
	 long int shomareParvaz;

};
struct list{
	list *next;
	list *prev;
	list *temp;
	list *tempezafi;


};	list *head;

flight::flight(){
	head=NULL;
}

flight::~flight(){
	list *temp=head;
	while ( temp != NULL ){
		list *tempezafi=temp;
		temp=temp->next;
		delete tempezafi;

	
	}
	
}

void flight::Add_List(string md , string ms ,  long int sp){
	if ( head == NULL ) {
		head = new list (md , ms , sp );
		system ("cls");
           cout <<" \t Data Succesfully Added"<<endl;
		   system("Pause");
		   system("cls");
	
	}
	else {
	list *temp = head; 
	while ( temp->next != NULL ){
		temp = temp->next;
		temp = new list (md , ms , sp);
		cout <<" \t Data Succesfully Added\n"<<endl;
		   system("Pause");
		   system("cls");
	}


	}


}

...
error C2511: 'void flight::Add_List(std::string,std::string,long)' : overloaded member function not found in 'flight'
can some one help me?
Last edited on
closed account (o3hC5Di1)
Hi there,

My guess is that you need to put the argument datatypes in the method prototype:

1
2
//line 8
void Add_List(string, string, long);


Hope that helps.

All the best,
NwN
The parameters are missing from the function declaration.
@ NwN & Peter87 thanks
i changed line 8 and now i get this error :
error C2661: 'list::list' : no overloaded function takes 3 arguments
can i insert "struct list" in private and add my argument in structure??
There is another way to solve this problem?
Last edited on
closed account (o3hC5Di1)
I believe you are not using list as you're supposed to.

The ways to create a list are described here:
http://www.cplusplus.com/reference/stl/list/list/

You can find plenty of examples to use lists here:
http://www.cplusplus.com/reference/stl/list/ (check the methods)

Maybe someone more advanced then myself can give you an alternative solution without lists.

All the best,
NwN
thanks : )
Topic archived. No new replies allowed.