简体   繁体   English

'未声明的标识符'/'标识符“x”未定义'/'class Y没有成员“x”'使用结构类型指针

[英]'Undeclared identifier' / 'identifier "x" undefined' / 'class Y has no member "x" ' working with struct-type pointers

I have my class Queue (declared in Queue.h and implemented in Queue.cpp) and the 'Node' struct defined in the Queue.h file, like this:我有我的类 Queue(在 Queue.h 中声明并在 Queue.cpp 中实现)和 Queue.h 文件中定义的“节点”结构,如下所示:

Queue.h队列.h

//...
typedef int TElem;
struct Node{
    TElem data;
    Node *next;
};
class Queue
{
private:
    Node *head;
    Node *tail;
public:
    // ... some other methods
}

Then, in Queue.cpp然后,在Queue.cpp

//...
Queue::Queue()
{
    head = nullptr;
    tail = nullptr;
}

These last 2 lines of code in my constructor produce 4 errors, two for each line: 'identifier "head" is undefined' / 'identifier "tail" is undefined' and "'head': undeclared identifier" / "'tail': undeclared identifier".我的构造函数中的最后 2 行代码产生 4 个错误,每行两个:'identifier "head" is undefined' / 'identifier "tail" is undefined' 和 "'head': undeclared identifier" / "'tail':未声明的标识符”。 Why is this and how can I solve this ?为什么会这样,我该如何解决? I have read answers to similar questions, yet none answered mine.我已经阅读了类似问题的答案,但没有人回答我的问题。

I am sorry for this, there was a problem with my files.很抱歉,我的文件有问题。 I did something bad with the files when creating the project.创建项目时,我对文件做了一些不好的事情。 The code ran just fine afterwards.之后代码运行得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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