[Error] request for member 'push' in 'q', which is of non-class type 'long long int'解释一下
时间: 2023-12-23 20:03:31 浏览: 57
这个错误是由于将一个非类类型的变量(在这种情况下是一个long long int类型的变量)当作类对象来使用导致的。在C++中,只有类对象才能调用成员函数(例如push()函数),而非类类型的变量不能直接调用成员函数。
要解决这个问题,你需要确保你将push()函数应用于正确的对象或类实例。如果你想使用push()函数来添加元素到容器中,你应该使用一个类对象(如vector、stack等)来调用该函数。如果你只是想在变量上调用一个函数,那么你应该使用适当的非成员函数或操作符。
请检查你的代码,确保你正在使用正确的语法和正确的类对象来调用成员函数。
相关问题
[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'.
error: request for member 'Compare' in 'n', which is of non-class type 'int'|
这个错误通常是因为你尝试在一个非类类型的变量上调用一个成员函数。在你的代码中,变量 `n` 被声明为 `int` 类型,但是你尝试在它上面调用一个名为 `Compare` 的成员函数。这是不合法的,因为 `int` 类型没有 `Compare` 成员函数。
如果你想在一个类中使用 `Compare` 函数,你需要确保这个函数是该类的成员函数,并且你要在类的对象上调用它。如果你只是想在一个普通的函数中使用 `Compare` 函数,你需要将其定义为一个非成员函数,并传递任何必要的参数。