超载 std::sqrt
Overloading std::sqrt
我试过像这样从 <cmath>
重载 std::sqrt
:
class MyClass {
...
}
MyClass std::sqrt(const MyClass& arg) {
...
}
但失败并出现错误
namespace "std" has no member "sqrt"
.
我在 Visual Studio
中使用 MS c++ 编译器
有人知道怎么做吗?
namespace std {
MyClass sqrt(const MyClass& arg) {
// ...
}
}
我试过像这样从 <cmath>
重载 std::sqrt
:
class MyClass {
...
}
MyClass std::sqrt(const MyClass& arg) {
...
}
但失败并出现错误
namespace "std" has no member "sqrt"
.
我在 Visual Studio
中使用 MS c++ 编译器有人知道怎么做吗?
namespace std {
MyClass sqrt(const MyClass& arg) {
// ...
}
}