0xC0000005: 读取位置 0xCDCDCDCD 时发生访问冲突。

void shop::Pay(){
if (basket == NULL)
return;
float sum = 0.0;
float sum_tax = 0.0;
for (i = 0; &basket[i] != NULL; i++)
{
basket[i].GetPrice();
sum_tax += basket[i].tax;
sum += basket[i].at_price;
}
cout << sum_tax << endl;
cout << "Total:" << sum << endl;
return;
}

void goods::GetPrice(){
if (this == NULL)
return;
float rate = 0.1f;
if (isExempt)
rate -= 0.1f;
if (isImported)
rate += 0.05f;
tax = count*price*rate;
at_price = count*price+tax;
cout << count << " " << name << ":" << at_price << endl;
}

在GetPrice执行第三次时报错,这是栈溢出吗?应该怎么改?虚心求教!

程序启动的时候,弹出如下错误框.......
答案就在这里:0xC0000005: 读取位置 0x01900014 时发生访问冲突
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

在GetPrice执行第三次时报错,具体 是调用语句处,还是执行GetPrice内的代码?
建议你调试一下,单步看看具体是哪一步出错了,然后重点分析这一步的代码其中用的变量等。
例如:basket[i] 在第三次执行时,其值是不是为空了???