error: request for member 'Compare' in 'n', which is of non-class type 'int'|
时间: 2023-12-21 19:06:18 浏览: 65
这个错误通常是因为你尝试在一个非类类型的变量上调用一个成员函数。在你的代码中,变量 `n` 被声明为 `int` 类型,但是你尝试在它上面调用一个名为 `Compare` 的成员函数。这是不合法的,因为 `int` 类型没有 `Compare` 成员函数。
如果你想在一个类中使用 `Compare` 函数,你需要确保这个函数是该类的成员函数,并且你要在类的对象上调用它。如果你只是想在一个普通的函数中使用 `Compare` 函数,你需要将其定义为一个非成员函数,并传递任何必要的参数。
相关问题
error: request for member 'Getpop' in 'S', which is of non-class type 'SeqStack<int>()'|
This error message suggests that you are trying to call the member function 'Getpop' on an object 'S' that is not a class type, but rather an instance of the template class 'SeqStack<int>()'.
To fix this error, you need to create an instance of the 'SeqStack<int>' class and call the 'Getpop' member function on that instance. Here's an example:
```
SeqStack<int> S; // create an instance of SeqStack<int>
int x = S.Getpop(); // call the Getpop member function on S and store the result in x
```
[Error] request for member 'pos' in 'k', which is of non-class type 'int'
This error occurs when you try to access the member variable 'pos' of an object 'k', but 'k' is not a class or struct type. This means that 'k' is probably defined as an integer or some other primitive data type, which does not have any member variables.
To fix this error, you need to make sure that 'k' is of a class or struct type that actually has a 'pos' member variable. Alternatively, you may need to adjust your code to use a different variable or approach that is appropriate for the data type of 'k'.