D:\data structure\homework(c)\main.cpp|183|error: base operand of '->' has non-pointer type 'NODE<int>'|
时间: 2023-05-24 14:06:59 浏览: 170
This error message suggests that you are trying to use the "->" operator on a variable that is not a pointer. The "->" operator is used to access a member of a pointed-to object.
For example, if you have a pointer to a struct called "person":
```c++
struct person {
string name;
int age;
};
person* ptr_person = new person;
```
You can access the "name" member using "->":
```c++
ptr_person->name = "John";
```
However, if you try to use "->" on a non-pointer variable, you will get the error you described:
```c++
NODE<int> myNode;
myNode->data = 5; // Error: myNode is not a pointer
```
To fix this error, you should use the "." operator instead of "->" when accessing members of non-pointer objects:
```c++
NODE<int> myNode;
myNode.data = 5; // This is correct
```
阅读全文