简体   繁体   English

结构对.cpp不可见

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM