How can an object change the value of QUANTITY
? It was 20, will be one less.
2 answers
I see 2 ways:
- Define your cart class by inheriting from WBasket, where you add the Public function to change the value of QUANTITY.
- You can directly in your existing class add your function to change the value of QUANTITY.
|
$object->QUANTITY -= 1;
Um ... I do not understand the question?
Added by
If QUANTITY is a private property, then there is only one option: add a function in the class that changes this property. Inheritance here does not roll, because the property is closed.
public function changeQuantity($n){$this->QUANTITY += $n;}
- the question was changed for some reason, there was a dump of the WBasket class object, so QUANTITY is a private property of the class and so you will not change it - Ale_x
- Updated the answer. - ling
|