I'm getting Illegal Indirection errors on lines 15 and 16 and I'm not sure why. I think it has something to do with pointers. Obviously I'm a beginner and could use any input you might have.
Thanks
#include <iostream>
using namespace std;
#define simp 0.10;
#define comp 0.05;
#define begin 100.00;
int main()
{
double daphne = begin;
double cleo = begin;
int years = 0;
while (cleo <= daphne)
{
daphne = begin * simp;
cleo = comp * cleo;
++years;
}
You shouldn't even be using #defines anyway. use constants:
1 2 3
constdouble simp = 0.10; // this will fix your problem
constdouble comp = 0.05;
constdouble begin = 100.00;
There are many reasons why you should not use #define for constants. I won't get into them here, just trust me. Avoid #define.
To further explain what was going on:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#define simp 0.10;
#define begin 100.00;
// the semicolons here are problematic
// remember that #define effectively copy/pastes... so when you do this:
daphne = begin * simp;
// begin is #defined as "100.00;" and
// simp is #defined as "0.10;"
// so you're left with:
daphne = 100.00; * 0.10;;
// the compiler assigns 100 to daphne, then doesn't know wtf you mean by *0.10;