I found a few topics that might have related, but only in C or C#, not C++. Since I'm so new to C++, I wasn't sure if those questions/answers applied. But I noticed that when I initialized a variable in my main method, if I tried to cout its value, it would return a memory location and not the variable's value.
The code I wrote (comments in the code expressing what I experienced):
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
bool gameOver = true;
//int heights [5];
vector <int> heights;
int count; // This returns a number
int main()
{
int height;
int inch;
int total;
//int count; this returns a memory location (I think?)
double average;
while (gameOver)
{
cout << "Enter height in inches, or 'end' to quit: ";
cin >> height;
heights.push_back(height);
count++;
cout << count;
if (count == 5)
{
gameOver = false;
}
}
for (int i = 0; i < sizeof(heights); i++)
{
total += heights[i];
}
average = (total / count);
return 0;
}
So, what's the difference between where it's initialized from?