[Solved] Warning driving me crazy...
Moderator: Coders of Rage
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
[Solved] Warning driving me crazy...
I decided to work on my my ATM simulator some more
and I ended up restructuring it using pointers since I
like them now..but this 1 warning is driving me nuts:
warning C4715: 'Account::saveWithdraw' : not all control paths return a value
My function returns the value it is supposed to and I
double checked everything leading to it but I still
can't find out why and I did search this on google.
I believe it has to be something in that function
causing the problem but to me the code looks
just fine......
and I ended up restructuring it using pointers since I
like them now..but this 1 warning is driving me nuts:
warning C4715: 'Account::saveWithdraw' : not all control paths return a value
My function returns the value it is supposed to and I
double checked everything leading to it but I still
can't find out why and I did search this on google.
I believe it has to be something in that function
causing the problem but to me the code looks
just fine......
Last edited by zodiac976 on Thu Jul 02, 2009 6:10 am, edited 1 time in total.
- ismetteren
- Chaos Rift Junior
- Posts: 276
- Joined: Mon Jul 21, 2008 4:13 pm
Re: Warning driving me crazy...
Have you cheked that there is a return statement inside ALL if-statements, loops, switches, etc. and also one outiside?
Maybe you could post the function?
Maybe you could post the function?
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: Warning driving me crazy...
I am pretty sure it is returning what it is supposed toismetteren wrote:Have you cheked that there is a return statement inside ALL if-statements, loops, switches, etc. and also one outiside?
Maybe you could post the function?
but I am more than likely not seeing something....
Don't laugh! this code is like 2 months old, I don't quite
remember what was wrong with it before and I code a
little different now but I just wanted to get the program
to work then I can change some stuff...anywho here is
my masterpiece rofl...
Code: Select all
string Account::saveWithdraw()
{ //Saves the amount of withdraws
string copyWitStr, tempW, tempAcc, tempPass;
double confWit, tempWit, tempBal;
bool loopChk = true;
char nextChar;
static double newWit = 0.0;
ifstream file1("Buffer.txt");
file1 >> tempAcc;
file1 >> tempPass;
file1 >> tempBal;
file1.close();
while(loopChk == true)
{
cls();
cout << " Withdraw\n"
<< "--------------------------------------\n";
cout << "Please enter the amount to withdraw: $";
getline(cin, tempW);
for(int x = 0; x < int(tempW.length()); ++x)
{
nextChar = tempW.at(x);
if(isalpha(nextChar))
{
cout << "\nInvalid amount...please re-enter your amount\n";
pause();
loopChk = true;
}
else
loopChk = false;
}
if(loopChk == true)
continue;
stringstream input2(tempW);
input2 >> tempWit;
confWit = tempBal - tempWit;
if(confWit <= 25.00)
{
cout << "\nCannot withdraw anymore money...please deposit money first\n";
pause();
continue;
}
else
break;
}
if(newWit != 0.0)
tempWit += newWit;
newWit = tempWit;
if(newWit < 25.00)
//Not working for some weird reason "says output is undeclared".
//stringstream output;
//output << tempWit;
//tempW = output.str();
return tempW;
}
when I get that warning fixed and also the commented part
of the code to....
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: Warning driving me crazy...
Never mind, I figured it out lmao...I am sad, I can't believe
I didn't notice it. I had an if statement without a statement..
EDIT: I spent hours and hours trying to figure out why...............

I didn't notice it. I had an if statement without a statement..

EDIT: I spent hours and hours trying to figure out why...............


- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Warning driving me crazy...
Just make sure you don't mess up "=" and "==". It may seem simple enough, but debugging that mistake has literally taken several hours of my life away.zodiac976 wrote:Never mind, I figured it out lmao...I am sad, I can't believe
I didn't notice it. I had an if statement without a statement..
EDIT: I spent hours and hours trying to figure out why...............![]()
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Warning driving me crazy...
Because you don't have braces on your if statement. This means that output is declared if newWit is < 25 and goes out of scope on the next line, because variables declared inside braces become invalid once execution exits the brace (this means that variables declared inside a loop are re-declared on every loop iteration, because execution leaves the braces to check the loop condition).Code: Select all
if(newWit < 25.00) //Not working for some weird reason "says output is undeclared". //stringstream output; //output << tempWit; //tempW = output.str();
So what you have is equivalent to
Code: Select all
if(newWit < 25.00) {
stringstream output;
}
output << tempWit;
tempW = output.str();
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: [Solved] Warning driving me crazy...
Yea I decided to just redo the whole project because it's
not doing what I want it to do...so I am taking it slower
this time and maybe it will work out right.
not doing what I want it to do...so I am taking it slower
this time and maybe it will work out right.
Re: [Solved] Warning driving me crazy...
Get used to it... Rewrites are something that happen alllll the time...
I rewrote my first blitzbasic game 3 or 4 times...


Re: [Solved] Warning driving me crazy...
I hate to burst anyones bubble, but planning the project on paper makes it much easier to go where you want.
That is, not down to the smallest detail, but thorough enough to have something to lead you when you get astray
That is, not down to the smallest detail, but thorough enough to have something to lead you when you get astray

- zodiac976
- Chaos Rift Regular
- Posts: 156
- Joined: Thu Jun 18, 2009 10:03 am
- Current Project: Booklet & Text RPG
- Favorite Gaming Platforms: PC, PS3, PSP
- Programming Language of Choice: C++
- Location: AL
- Contact:
Re: [Solved] Warning driving me crazy...
I know I always jump on the computer saying I want toScoody wrote:I hate to burst anyones bubble, but planning the project on paper makes it much easier to go where you want.
That is, not down to the smallest detail, but thorough enough to have something to lead you when you get astray
do this and start throwing it together....a bad habit I
guess.
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: [Solved] Warning driving me crazy...
My problem with this is I never actually know where I want to go. I have a hard time coming up with ideas for projects to work on for some reason.Scoody wrote:I hate to burst anyones bubble, but planning the project on paper makes it much easier to go where you want.
That is, not down to the smallest detail, but thorough enough to have something to lead you when you get astray
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!