I tried to change a Price value of the object (to increace it by one), but i got a problem as it stay the same (no changes at all). It works fine inside of the method ,but It doesn't work when i display it in the main function. I would appreciate any help. method
void Tovar::increasingPriceValue(vector<Tovar> nameOfTheVector){
int i;
Tovar x;
cout << "Enter number of element from array:";
cin >> i;
x.Price = nameOfTheVector[i].Price + 1;
nameOfTheVector[i].SetPrice(x.Price);
}
And here is main
int main() {
vector<Tovar>product;
string menu = "Enter the option which you want to choose:\n1) Input inforamtion\n2) Displaying on the screen\n3) Exit\n";
int option,incdec, DayOfReceipt_, MounthOfReceipt_, YearOfReceipt_, NumberOfRecievedProducts_, CurrentDay_, CurrentMounth_, CurrentYear_, NumberOfProductsThatLeft_;
string Name_;
float Price_;
Tovar x,y,z;
x = Tovar();
y=Tovar();
while (true) {
cout << menu;
cin >> option;
switch (option) {
case 1: //Input
cout << "Enter the name of the product: ";
cin >> Name_;
x.SetName(Name_);
cout << "Enter the price of the product: ";
cin >> Price_;
x.SetPrice(Price_);
cout << "Enter the date when you received products:\n";
cout << "Day: ";
cin >> DayOfReceipt_;
cout << "Mounth: ";
cin >> MounthOfReceipt_;
cout << "Year: ";
cin >> YearOfReceipt_;
x.SetDateOfReceipt(DayOfReceipt_,MounthOfReceipt_, YearOfReceipt_);
cout<<"Enter the number of recieved Products: ";
cin>>NumberOfRecievedProducts_;
x.SetNumberOfReceivedProducts(NumberOfRecievedProducts_);
cout << "Enter the current date:\n";
cout << "Day: ";
cin >> CurrentDay_;
cout << "Mounth: ";
cin >> CurrentMounth_;
cout << "Year: ";
cin >> CurrentYear_;
x.SetCurrentDate(CurrentDay_,CurrentMounth_,CurrentYear_);
cout << "Enter the number of products that left: ";
cin >> NumberOfProductsThatLeft_;
x.SetNumberOfProductsThatLeft(NumberOfProductsThatLeft_);
z=Tovar(Name_,DayOfReceipt_,MounthOfReceipt_,YearOfReceipt_,NumberOfRecievedProducts_,CurrentDay_,CurrentMounth_,CurrentYear_,NumberOfProductsThatLeft_,Price_);
product.push_back(z);
product.push_back(x);
y=Tovar(x);
product.push_back(y);
cout<<"Enter 1 to increase price:\nEnter 2 to decreace price: \nEnter 3 to not change price:\n";
cin>>incdec;
switch(incdec){
case 1:{
x.increasingPriceValue(product);
break;
}
case 2: //display on the screen
PrintTab(product);