I'm coding a small Wind app to help my kids practise their fractions (and get me into Win app development). The app is based on a series of Dialogs because I have no need to save data. The dialog has some read-only edit boxes which display two randomly-generated fractions, for example 2/5 * 3/8, and edit boxes which receive the user's answer input.
Each fraction is generated from a GenericFraction class which has a private numerator and denominator and overloaded arithmetical operators + - * /. The dialog initialization is shown below.
// on dialog initialization, disable the 'Next Question' button.
// call for appropriate text for the Practise Results screen title
? "Addition Practise Results (Random Session)"
: "Addition Practise Results");
// Create values for first question. Instantiate two fractions for
// the first question and populate the numerators and denominators
GenericFraction *gf1Ptr = new GenericFraction(m_Scope);
m_Num1 = gf1Ptr->getNumerator();
m_Den1 = gf1Ptr->getDenominator();
GenericFraction *gf2Ptr = new GenericFraction(m_Scope);
m_Num2 = gf2Ptr->getNumerator();
m_Den2 = gf2Ptr->getDenominator();
// show the generated fraction values
return TRUE; }
Two new fractions are instantiated and their data stored. I have traced the program using debug and different fractions are generated (I have ensured this with code elsewhere), but when the dialog is instantiated, the second fraction numerator and denominator values are the same as the first fraction values on the screen. Why would that be? I have tried approaching this several ways. I must be missing something simple here.