从函数返回类型分配类型的正确方法是什么?
class Vector2 {
private:
float x, y;
public:
Vector2(float _x, float _y) {
x = _x;
y = _y;
}
// Dot product
float operator*(const Vector2& other) {
return x * other.x + y * other.y;
}
// Magnitude (abs)
float Magnitude() {
float dot = (this) * (this); // HERE IS THE ERROR: expression must have arithmetic or unscoped enum type
return std::sqrt(dot);
}
Vector2 operator+(const Vector2& other) {
return Vector2(x + other.x, y + other.y);
}
};
如VSCode所示,返回类型可用。我只是不知道如何在不调用函数的情况下获取它。
答案 0 :(得分:0)
可能不符合 JSDoc 规范,但 VS Code 支持 JSDoc 中的 Typescript 语法。
SELECT *
FROM (SELECT Name, Price, AVG(Price) OVER (PARTITION BY Name) AS Average_Price
FROM items) AS X
WHERE X.Price > X.Average_Price