shebo
Member level 2
- Joined
- Mar 28, 2006
- Messages
- 42
- Helped
- 5
- Reputation
- 10
- Reaction score
- 3
- Trophy points
- 1,288
- Location
- do you ever care?
- Activity points
- 1,553
i'm using VC++
which is performance wise ?
1 -
CDMatrix& CDMatrix:perator -(CDMatrix& in)
{
for(int i=0;i < this->row ;i++)
{
for(int j=0;j < this->column ;j++)
{
tmp.MData[j]=MData[j]-in.MData[j];
}
}
return(tmp);
}
where tmp is a new object of the class CDMatrix
or
2-
void CDMatrix:perator-=(CDMatrix& IM){
for(int i=0;i < this->row ;i++)
{
for(int j=0;j < this->column ;j++)
{
this->MData[j]=this->MData[j]-IM.MData[j];
}
}
}
where the return value is *this
which is performance wise ?
1 -
CDMatrix& CDMatrix:perator -(CDMatrix& in)
{
for(int i=0;i < this->row ;i++)
{
for(int j=0;j < this->column ;j++)
{
tmp.MData[j]=MData[j]-in.MData[j];
}
}
return(tmp);
}
where tmp is a new object of the class CDMatrix
or
2-
void CDMatrix:perator-=(CDMatrix& IM){
for(int i=0;i < this->row ;i++)
{
for(int j=0;j < this->column ;j++)
{
this->MData[j]=this->MData[j]-IM.MData[j];
}
}
}
where the return value is *this