Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

课后练习14.52 LongDouble转SmallInt的方式 #87

Open
EnzoFerrari430 opened this issue Dec 2, 2018 · 0 comments
Open

课后练习14.52 LongDouble转SmallInt的方式 #87

EnzoFerrari430 opened this issue Dec 2, 2018 · 0 comments

Comments

@EnzoFerrari430
Copy link

ld = si + ld;
我看很多人都说只能转换成内置类型进行相加operator+(int,float)或者operator+(int,double)
为什么下面这种不行呢
friend SmallInt operator+(const SmallInt &,const SmallInt &);
ld可以先转换成float或者double然后再转换成int。SmallInt可以调用SmallInt(int = 0); 构造一个临时对象
然后得到SmallInt再转换成int类型,再转换成double最后调用LongDouble(double = 0.0);构造一个临时对象。这种方式不行吗?虽然也会产生二义性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant