问题描述
void CalcPortGrossRet(Funds tf [],int fsize,PortFolio tp,int cmonth)
{
int i = 0;
float totgrossdlrval = 0;
char converter [10];
while(i< fsize){
tf [i] .enddlrval =( tf [i] .dlrval *(tf [i] .ret [cmonth] /100.0)+ tf [i] .dlrval);
totgrossdlrval + = tf [i] .enddlrval;
i ++;
}
tp.grossenddlrval = totgrossdlrval;
tp.ret [cmonth] =(tp.grossenddlrval-tp .grossdlrval)/tp.grossdlrval;
sprintf(转换器,"%。5f",tp.ret [cmonth]);
MessageBox(NULL," Monthly)投资组合的回报是
+(CString)转换器,C ++ Debugger,NULL);
}
在使用
CalcPortGrossRet(thefunds,3,theport,im)调用CalcPortGrossRet后
;
并返回,
theport.grossenddlrval它有垃圾。
函数tp.grossenddlrval是正确的。
tp.grossenddlrval是一个浮点数。
t heport在调用函数中定义。
发生了什么?
感谢
void CalcPortGrossRet(Funds tf[],int fsize,PortFolio tp,int cmonth)
{
int i=0;
float totgrossdlrval=0;
char converter[10];
while(i<fsize){
tf[i].enddlrval=(tf[i].dlrval*(tf[i].ret[cmonth]/100.0)+tf[i].dlrval);
totgrossdlrval+=tf[i].enddlrval;
i++;
}
tp.grossenddlrval=totgrossdlrval;
tp.ret[cmonth]=(tp.grossenddlrval-tp.grossdlrval)/tp.grossdlrval;
sprintf(converter,"%.5f",tp.ret[cmonth]);
MessageBox(NULL,"Monthly return for portfolio is "
+ (CString)converter,"C++ Debugger",NULL);
}
after CalcPortGrossRet is called with
CalcPortGrossRet(thefunds,3,theport,im);
and returns,
theport.grossenddlrval has garbage in it.
While in function tp.grossenddlrval is correct.
tp.grossenddlrval is a float.
theport is defined in the calling function.
whats happening?
thanks
推荐答案
tp是一个对象。它是否有正确的拷贝构造函数?
/ dan
tp is an object. Does it have the proper copy constructor?
/dan
-
A:因为它混乱人们通常阅读文字的顺序。
问:为什么这么糟糕?
A:热门帖子。
问:usenet和电子邮件中最烦人的事情是什么?
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
这篇关于问题传递价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!