Possible Duplicate:
Request for member which is of non-class
So I’ve created an ADT which is a singly linked list made up of nodes. These Nodes each have a pointer to an object in them called data.
Class Structure
{
private:
struct Node
{
Object *data;
Node *next;
};
Node *head;
};
I am trying to call a function in the object, like this:
head = new Node;
head -> data = new Object();
head -> next = NULL;
cout << head -> data.print();
I keep getting the following error at compile.
error: request for member ‘print’ in ‘head->Structure::Node::data’, which is of non-class type ‘Object‘*
edit: Thanks for the quick answers, amazing community. Extremely stupid mistake on my part, I feel like a fool heh 😛
datais a pointer, perhaps you need? Or, if the function
printdoes the printing itself, maybe just