Parallel Arrays

I have a problem with my identifiers in my program and some other error messages i am not sure about. i have been trying to work out these but just van not figure them out if someone could give me some help it would be awesome.
#include <iostream>
#include <iomanip>
using namespace std;
int getTotal();
void price();
int dispTotal();
int main()
{
price();
getTotal();
dispTotal();
return 0;
}

void price()
{const int SIZE = 8;//size of array
int quanity[SIZE];
double price[SIZE];

//Price for Each
cout<<"Enter the price per product and the quanity "<<endl;
for (int i = 0; i < SIZE; i++)
{ cout<<"Price for product "<<i+1<<" : "<<endl;
cin >> price[i];
cout<<"Quanity of product "<<i+1<<" : "<<endl;
cin>> quanity[i];

}
}
int getTotal()
{ int total;
int quanity[i++];
int price[i++];
for (int i = 0; i < SIZE; i++)
{total= price[i++]*quanity[i++]};
return total;

}
int dispTotal()
{int total;
cout<<"total "<<total<<endl;
return 0;


and the error messages are
1>c:\users\andrew\desktop\lab10\lab10\andrewwells_10_2.cpp(34): error C2065: 'SIZE' : undeclared identifier
1>c:\users\andrew\desktop\lab10\lab10\andrewwells_10_2.cpp(35): error C2109: subscript requires array or pointer type
1>c:\users\andrew\desktop\lab10\lab10\andrewwells_10_2.cpp(35): error C2109: subscript requires array or pointer type
1>c:\users\andrew\desktop\lab10\lab10\andrewwells_10_2.cpp(35): error C2143: syntax error : missing ';' before '}'

Thanks in advance
}
It looks like a scope issue.

You define SIZE in your 'price' function. Since it's local to that function it does not exist outside of it. So when you try to access 'SIZE' in other functions (like getTotal), it doesn't exist.

You either need to define SIZE again in each function, give it a broader scope (global), or pass it to each function it's used in.
What is the best way to pass it to each function? I do not understand how to pass it correctly i have tried to but i just keep messing it up more than it already is.
Topic archived. No new replies allowed.