Operator overload = not copying to 2nd variable-object

45 Views Asked by At

Trying to just copy one object array to a second array minus first item in array (which I don't believe should matter). (First array 33 items and 2nd array has 32). Nothing is copying over. 2nd array has constructor values when printed after function. Am I not "pointing" correctly? I don't have a good grasp of pointers or *this operator. My other overload functions appear to work fine. I am copying to drop the first member of the array because when I sort, I cannot get the sort correct (it includes the first). So I am trying to find my issue with that process in this manner and have found that my copy is not working.

Print first array - values good. Make copy and print of second has constructor values. Been searching/reading across Internet. Stumped. Other object functions working fine. I am having trouble getting proper formatting of code...sorry.

` Team* Tm; Tm = new Team[33];

Team* Tm2;
Tm2 = new Team[33];

for (int j = 1; j < NumberOf.GetNumTeamsNFL() + 1; ++j) {
    Tm[j] = Tm2[j-1];
}// End of copy to Tm2[]
Team Team::operator=(Team & Tm)
{
 Base::operator=(Tm);
 Position = (Tm.GetPosition());
 GamesPlayd = (Tm.GetGamesPlayd());
 wins = (Tm.GetWins());
 loss = (Tm.GetLoss());
 ties = (Tm.GetTies());
 DivWins = (Tm.GetDivWins());      
 DivLoss = (Tm.GetDivLoss());     
 DivTies = (Tm.GetDivTies());     
 ConfWins = (Tm.GetConfWins());   
 ConfLoss = (Tm.GetConfLoss());   
 ConfTies = (Tm.GetConfTies());   
 ptsscrd = (Tm.GetPtsScored());
 ptsalwd = (Tm.GetPtsAllowd());
 ofr = (Tm.GetOfr());
 dfr = (Tm.GetDfr());
 PlayOffPoints = (Tm.GetPlayOffPoints());
 PlayOffSeed = (Tm.GetPlayOffSeed());
 WLTPercentage = (Tm.GetWLTPercentage());
 return *this;
}// End of operator= overload.`
1

There are 1 best solutions below

1
Nat Broughton On

I found my issue after days of looking and trying different ideas. I was copying the new to the old not old to new object. I don't know how to close the question.