-6
有人可以告诉我为什么我有随机结果吗?为什么我在此模板上有一个随机结果?
template<class T, class U>
T f(T x, U y)
{
return x+y;
}
int f(int x, int y)
{
return x-y;
}
int main()
{
int *a=new int(3), b(23);
cout<<*f(a,b);
return 0;
}
什么B(23)意味着什么?万分感谢 !
什么“随机结果”你在说什么? – AnT
'*(new int(23)+ 23)'确实是UB。 – Jarod42
我每次都得到不同的结果 –