Hello:
Something as seemingly simple as an If\ Else statement is causing me much trouble and I cannot figure out where the error lies. I believe it to be in:
- The variable scope
- The use of the static variable
- Or, the misplacement of curly brackets (something that has a tendency to trip me up at times)
Also, while debugging, the variable of "shipPos" should be 228 at different points (and it couts as this) but the debugger refers to the value as "-1.0737418e+008" This honestly does not make sense to me-- I assumed it to be the memory location (?) but why would that be in this case?
Any hints, help, or shove in the right direction would be surely appreciated.
Regards
sharky_machine
#include <ctime>
#include <cstdlib>
#include <iostream>
#include "Look.h"
using namespace std;
int checkFlag ;
int* pTest;
Look::Look() {
}
Look::~Look() {
}
void Look::printShipPos()
{
if (checkFlag > 0) {
static int shipPos = 0;
//-------------------------Pointer Test
//pTest = &shipPos;
//cout << pTest << endl;
//cout << *pTest << endl; // Works!
//-------------------------Pointer Test
cout << shipPos << "_shipPos 1"<<endl;
shipPos = shipPos + 228;
cout << shipPos << "_shipPos added"<< endl;
}
//{
//RECHECK all values below
if (shipPos == 228) {
std::cout << "French Polynesia [Out of Transmission Range]"<<endl;
else if (shipPos == 456){
std::cout << "Maui, Hawaii [Out of Transmission Range]"<< endl;
}
/* else if ((shipPos >= 456) && (shipPos < 684)){
std::cout << "Pacific Ocean (open waters) [Out of Transmission Range] 4320 miles from Tampa, Florida"<< endl;
}
else if ((shipPos >= 684) && (shipPos < 912)) {
std::cout << "Pacific Ocean (open waters) [In Transmission Range] 3240 miles from Tampa, Florida"<< endl;
} */
[B].
.
.[/B]
//---------------------counter for fly-over access
checkFlag++;
cout <<checkFlag<< endl;
return;
// }
}