如何在 c++ 中扩展 mpz_class
我想创建我自己的类,它与 mpz_class 类似,但有一些额外的方法。然而,我听说扩展 std
类不是一个好主意。这个建议是否适用于这里或者我可以安全地这样做:
class MyBigInt : public mpz_class {
public:
long double specialMethod() {
//do something that returns a long double
}
}
我对扩展感兴趣的原因是我仍然希望能够
mpz_class a,b,c;
a=5;
b=6;
c=a+b;
这样做,如果扩展是一个坏主意我需要一些如何弄清楚如何使上述工作与我自己的类一起工作。
I want to create my own class that is similar to mpz_class
except has a few extra methods. I have however heard it is not a good idea to extend std
classes. Does this advice apply here or can I safely do:
class MyBigInt : public mpz_class {
public:
long double specialMethod() {
//do something that returns a long double
}
}
The reason I am interested in extending is I still want the ability to do
mpz_class a,b,c;
a=5;
b=6;
c=a+b;
so if extending is a bad idea I need to some how figure out how to make the above work with my own class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论