重载std :: sqrt

问题描述 投票:0回答:1

我试图像这样从std::sqrt重载<cmath>

class MyClass {
    ...
}

MyClass std::sqrt(const MyClass& arg) {
    ...
}

但是失败并显示错误namespace "std" has no member "sqrt"

我在Visual Studio中使用MS c ++编译器

有人知道怎么做吗?

c++ overloading sqrt
1个回答
0
投票
namespace std {
    MyClass sqrt(const MyClass& arg) {
        // ...
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.