[英]Struct is not visible to .cpp
I declared a struct at header file, you can see it below. 我在头文件中声明了一个struct,你可以在下面看到它。
private:
struct Node{
Customer data;
Node *next;
Node *prev;
};
Node* find (const int index) const;
And declared a function that returns Node*
private. 并声明了一个返回
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 ". 但是,当我尝试在我的cpp文件中实现函数
find
时,它会出现错误,指出“ 标识符节点未定义 ”。
Node* CustomerList::find(const int index){
//some random code
}
What is the problem, isn't Node
supposed to be visible to the .cpp ? 有什么问题,不是
Node
应该对.cpp可见吗?
Assuming CustomerList
is the class containing Node
. 假设
CustomerList
是包含Node
的类。
CustomerList::Node* CustomerList::find(const int index){
//some random code
}
Within a CustomerList
method you can just say Node
but the return type is different, you still need to qualify with CustomerList::
在
CustomerList
方法中,您可以说Node
但返回类型不同,您仍然需要使用CustomerList::
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.