So..I'm测试与断言的函数:(pBola1的值是1)是否有可能看到在C++中返回的值?
assert(BomboTest.TreureBola(1)==pBola1);
BomboTest.TreureBola它返回一个随机数的函数(在这种情况下必须返回1)的一个列表。
cBola* cBombo::TreureBola(int num)
{
int posicio_aleatoria;
posicio_aleatoria= rand() % (num);
return(Boles.TreureElement(posicio_aleatoria));
}
而且TreureElement它返回一个动态列表知道你要提取的元素的位置的元素(在这种情况下返回“Retorn酒店”,这是1)
cBola* cLlista::TreureElement(int posicio)
{
int i;
cBola* recorreLlista;
cBola *retorn;
recorreLlista=primer;
retorn = primer;
i=0;
if (posicio == 0)
{
primer = (*primer).getSeguent();
}
else
{
// Busquem la posició //
while(i < posicio)
{
recorreLlista= retorn;
retorn = (*retorn).getSeguent();
i++;
}
(*recorreLlista).setSeguent((*retorn).getSeguent());
}
numElements--;
return retorn;
}
功能我不知道为什么,但断言失败。我可以看到TreureElement返回的值,因为我的指针'retorn',但我无法知道TreureBola返回的值。有什么方法可以看到TreureBola在调试器中返回的值?
PD:我使用Visual Studio 2010
使用简化的(变量|函数|类)名称作为示例代码通常是首选,因为它可以更容易阅读 – Legionair