C++: How do you set up an if-else statement for a return function
I am doing this for a math class and just cannot get the if-else statement
to work. Can someone tell me what I should do for the else statement? My
idea is to pass a vector into a function and every time the function sees
"close" it changes it to "open" and vice versa. The compiler always stops
at the if statement, that is nothing after the first element in the vector
gets changed :
string getValue(vector<string> &arr)
{
for(int i=2; i <=50; i++)
{
if(arr[i]=="close")
{
return arr[i]="open";
}
}
return "close";
}
No comments:
Post a Comment