Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating and implementing functions (C++).
#5
Ahh, that helps a lot, thanks! I still have another problem, though...

I've got errors stating that value is an undeclared variable, and I can see why now. But isn't there a way for the program to find it initialized outside of the function or would I have to declare these variables within the function?

So basically, as an example;

Code:
int InputCount (ifstream &inF)
{
    int valueCount = 0;        //Initialize the value count at 0.
    while (inF >> value)    
    {
        valueCount += 1;    //Increment value count.
    }
    return valueCount;
}

int main()
{
    float value;

-insert rest of code here-
}

EDIT: I ask this because the basic format of our program has the variable declaration inside the main function, and it sort of feels like I'll have all of my declarations within my declared functions.
Reply


Messages In This Thread
Creating and implementing functions (C++). - by MariettaRC - 2013-09-16, 12:52 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)