May 27, 2012 at 4:56pm UTC
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 May 27, 2012 at 4:57pm UTC
May 27, 2012 at 5:00pm UTC
The parameters are missing from the function declaration.
May 27, 2012 at 5:14pm UTC
@ 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 May 27, 2012 at 5:29pm UTC
May 27, 2012 at 6:01pm UTC
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