Sort of a follow up from my last question which I don't know how to properly ask so I'll start with some context:
When I compile the below code I get this compiler error:
______________________________________________________________________
source.cpp: In function 'int main()':
source.cpp:47:9: error: jump to case label [-fpermissive]
case 'q':
^
source.cpp:44:11: note: crosses initialization of 'Wallet temp'
Wallet temp(q,d,n,p);
^
source.cpp:51:4: error: jump to case label [-fpermissive]
default:
^
source.cpp:44:11: note: crosses initialization of 'Wallet temp'
Wallet temp(q,d,n,p);
^
___________________________________________________________________
1 2 3 4 5 6 7 8 9 10 11 12 13
|
case 'd':
int q, d, n, p;
cout << "quarters to deposit: ";
cin >> q;
cout << "dimes to deposit";
cin >> d;
cout << "nickels to deposit: ";
cin >> n;
cout << "pennies to deposit: ";
cin >> p;
Wallet temp(q,d,n,p);
userWallet.deposit_all_change(temp);
break;
|
I've tried different implementations but none have worked so far.
For example I've omitted the initialization of Wallet temp and changed the deposit line to userWallet.deposit_all_change(Wallet (q,d,n,p));.
But that doesn't work because my deposit method expects its parameter (wallet) to be passed by reference - which I can't figure out how to do.
(I've tried like this: 'userWallet.deposit_all_change(Wallet &(q,d,n,p))', I've tried attaching '&' to q,d,n,p individually, at this point I don't know if what I'm trying to do is impossible.
Been trying to figure this out for the past day and a half, but no old posts online seem to give me any hints. Thanks in advance.