Include header file problem

Hello, everybody
I am writing a program consists of three files main.cpp, and linklist.h and linklist.cpp. The code is not the final version cause I want to ensure this step first.
I believe that my problem is, in including the files, could you please check it and give you advice?

This is the first error:
request for member `select' in `list', which is of non-class type `linklist ()()'

These are the 3 files:

//------ main.cpp file ------
#include <iostream>
#include <ctype.h>
using namespace std;
#include "linklist.h"

int main()
{
int op;
linklist list();

do{
cout<< "Enter..." <<endl<< "1: to Add new dog"
<<endl<< "2: to Display the exist list"
<<endl<< "3: to Delete dog data"
<<endl<< "4: to Exit" <<endl<< "Your option is: ";
cin>> op;

list.select(op);

}while(cin.fail()!);


system("pause");
return 0;
}


//------ linklist.h ------
class linklist
{
public:
linklist();
void select(int);

private:
int opt;
};


//------ linklist.cpp ------
#include <iostream>
using namespace std;

#include "linklist.h";

linklist::linklist()
{
opt = 0;
}

void linklist::select(int opt)
{
switch (opt)
{
case 1:
{
break;
}

case 2:
{
break;
}

case 3:
{
break;
}

default:
{
cout<< "You have entered a undefined option, try again..." <<endl;
}
}
}
//------------------------
in your linklist.cpp try deleting the void so it says:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
linklist::select(int opt)
{
switch (opt)
{
case 1:
{
break;
}

case 2:
{
break;
}

case 3:
{
break;
}

default:
{
cout<< "You have entered a undefined option, try again..." <<endl;
}
}
Hi chimera,
It doesn't work. Could you try the code in your compiler?
this should work :

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
#include <iostream>
#include <ctype.h>
#include "linklist.h"

using namespace std;

int main()
{
int op;
linklist list;

do{
cout<< "Enter..." <<endl<< "1: to Add new dog"
<<endl<< "2: to Display the exist list"
<<endl<< "3: to Delete dog data"
<<endl<< "4: to Exit" <<endl<< "Your option is: ";
cin>> op;


list.select(op);

}while(true);


system("pause");
return 0;
}


however not sure what (cin.fail()!); should do so i replaced it cause i couldn't get it to work


1
2
3
4
5
6
7
8
9
class linklist
{
public:
linklist();
void select(int);

private:
int opt;
};


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
#include <iostream>
#include "linklist.h";

using namespace std;
linklist::linklist()
{
opt = 0;
}

void linklist::select(int)
{
switch (opt)
{
case 1:
{
break;
}

case 2:
{
break;
}

case 3:
{
break;
}

default:
{
cout<< "You have entered a undefined option, try again..." <<endl;
}
}
}

Yeaaa, It works ^_^ Thank you so much
no problem ;) just remember that you shouldn't write linklist list(); you only need the () when the constructor actually has paremeters, that was your problem ;)
Topic archived. No new replies allowed.