Related to C++ Basics.
I am creating a singly linked list.
class Linked_List
{
public: Linked_List();
~Linked_List();
//Member Functions
struct node* getHead(void);
private:
struct node{
int d;
struct node* next;
}*head;
};
struct node (Linked_List::*getHead)(void)
{
return head;
}
I am getting this error:
“error C2470: ‘getHead’ : looks like a function definition, but there is no parameter list; skipping apparent body”.
I tried to search in google but of no use. Any suggestions plz.
You don’t need a pointer to member function, you just want to provide a definition for that function:
Also notice, that the
structkeyword is unnecessary in the function definition, while you have to qualify the name of the structnodewith the name of the class in the scope of which it is defined.Also, the
voidkeyword to specify an empty argument list is unnecessary. I therefore suggest you to rewrite the class definition as follows: