Struct is not visible to .cpp-Collection of common programming errors
I declared a struct at header file, you can see it below.
private:
struct Node{
Customer data;
Node *next;
Node *prev;
};
Node* find (const int index) const;
And declared a function that returns Node* private.
However when I try to implement the function find at my cpp file, it gives an error saying that “identifier Node is undefined“.
Node* CustomerList::find(const int index){
//some random code
}
What is the problem, isn’t Node supposed to be visible to the .cpp ?
-
Assuming
CustomerListis the class containingNode.CustomerList::Node* CustomerList::find(const int index){ //some random code }Within a
CustomerListmethod you can just sayNodebut the return type is different, you still need to qualify withCustomerList::
Originally posted 2013-11-09 22:44:29.