This is my subfunction and I have no idea where is my codes wrong~~
Please help solve~~
Thank You Very Much~~
int add()
{
int x; //types of addtion int y; //types of y int amt; // amount int menu[y][x]; bool cond1 = true; bool cond2 = true;
cout<<"Which Drink(s) Do You Wish To Order : "; while(cond1)
{ if(cin>>y)
{ if(y != 0 || y != 1 || y != 2 || y != 3 || y != 4)
{cout<<endl<<"Please Choose Between 1,2,3,4,5!"<<endl;}
else
{ if(y=0)
{cout<<"Expresso\n";} elseif(y=1)
{cout<<"Cappucino\n";} elseif(y=2)
{cout<<"Latte\n";} elseif(y=3)
{cout<<"Hot Chocolate\n";} else
{cout<<"Plain Tea\n";}
cond1 = false;
}
} else
{
cin.clear();
cin.ignore(10000,'\n');
cout<<"Please Choose Between 1,2,3,4,5!"<<endl;
cout<<"Which Drink(s) Do You Wish To Order : ";
}
}
cout<<endl<<"Which Addition(s) Do You Wish To Add : "; while(cond2)
{ if(cin>>x)
{ if(x !=0 || x !=1 || x !=2 || x !=3)
{cout<<endl<<"Please Choose Between 1,2,3,4 !"<<endl;}
else
{ if(x=0)
{cout<<"Regular\n";} elseif(x=1)
{cout<<"Sugar\n";} elseif(x=2)
{cout<<"Milk\n";} else
{cout<<"Both\n";}
cond2= false;
}
}
}
cout<<"How Many Drink(s) Do You Want : ";
cin>>amt;
Here's the whole thing in code tags - hopefully a little easier to follow :)
In addition to what eyenrique mentioned about the equality operator, the size of an array needs to be set when the program is compiled, so you can't do something like this int menu[y][x]; with y and x not being defined yet.
//return_array_value.cpp
//##
#include <iostream>
usingnamespace std;
int f();
int main(){
cout<<f()<<endl;
return 0; //indicates success
}//@end of main
int f(){
int array[3][3]={1,2,3,4,5,6,7,8,9};
return array[1][1];
}//end function f
If I wish to return array location eg. array[3][2] from subfunction to main
array[3][2] is a single value.
it's effectively the same as this:
1 2
int x = 5;
return x;
If you are asking, how can you return the entire contents of the array, then perhaps it is simpler to define the array in main() and pass it as a parameter to the other function. http://www.cplusplus.com/doc/tutorial/arrays/