C++中 变量y0y1等变量 的冲突问题

本文解答了在使用#include<bits.stdc++.h>时遇到的错误:previous declaration of ‘double y1(double)’。问题源于math.h库中预定义的Bessel函数y1,与自定义变量名y1冲突。文章提供了Bessel函数的相关介绍,并建议避免使用这些函数名作为变量名。

之前在使用# include <bits.stdc++.h> 定义y1变量时出现下列错误信息

error: previous declaration of ‘double y1(double)’

自动弹出 了 math.h库中的源码解释
CRTIMP double __cdecl j0 (double);
_CRTIMP double __cdecl j1 (double);
_CRTIMP double __cdecl jn (int, double);
_CRTIMP double __cdecl y0 (double);
_CRTIMP double __cdecl y1 (double);
_CRTIMP double __cdecl yn (int, double);

_CRTIMP double __cdecl chgsign (double);

所以问题出在 math.h 库中

我们能看到 以上变量被征用 ,所以在使用math.h定义时 不能使用上面变量

大佬给出的 解释

Function: double j0 (double x)
j0 returns the Bessel function of the first kind of order 0 of x. It may signal underflow if x is too large.

Function: double j1 (double x)
j1 returns the Bessel function of the first kind of order 1 of x. It may signal underflow if x is too large.

Function: double jn (int n, double x)
jn returns the Bessel function of the first kind of order n of x. It may signal underflow if x is too large.

Function: double y0 (double x)
y0 returns the Bessel function of the second kind of order 0 of x. It may signal underflow if x is too large. If x is negative, y0 signals a domain error; if it is zero, y0 signals overflow and returns -∞.

Function: double y1 (double x)y1 returns the Bessel function of the second kind of order 1 of x. It may signal underflow if x is too large. If x is negative, y1 signals a domain error; if it is zero, y1 signals overflow and returns -∞.

Function: double yn (int n, double x)yn returns the Bessel function of the second kind of order n of x. It may signal underflow if x is too large. If x is negative, yn signals a domain error; if it is zero, yn signals overflow and returns -∞.

来自 知乎 @ sin1080 的回答

自己翻译吧,哈哈哈哈哈哈

Bessel Functions: _j0, _j1, _jn, _y0, _y1, _yn 多看msdn

Bessel function - Wikipedia然后可以在这里找到具体的内容

来自知乎 @ vczh 的回答

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值