Mail Archives: djgpp/1997/12/30/20:46:27
Here is a snippet of C++ code I have using the DJGPP compiler. This is
the constructor
definition for the class "investment". It works just fine as shown
below:
investment::investment(float initialAmount, float percentInterestRate,
float monthlyWithdrawl, char compoundMode, char monthlyOrYearlyBalance,
int numberYears)
{
char *newCompoundMode, tempCompoundMode;
newCompoundMode = 0;
tempCompoundMode = compoundMode;
newCompoundMode = strlwr(&tempCompoundMode);
.
.
.
}
Also, in my main program, I call this constructor with:
investment dadInvestment(23454.67, 9.2, 544.55, 'U', 'N', 2);
Why is it, however, that if I declare my local char variables in the
reverse order like:
char tempCompoundMode, *newCompoundMode;
I get a memory segmentation/GPF type of fault when I run it, but not
when I declare them
in the other order? Is it because we must always put pointers ahead of
regular variables in a
certain type declaration?
Also, I couldn't use the parameter "compoundMode" directly as in:
newCompoundMode = strlwr(&compoundMode);
This gives me the above mentioned crash and burn as well. Any ideas on
either of these
two weird quirks?
- Raw text -