Without knowing the use case or the actual problem you want to solve (please read the XY problem , your question is a good example of this) the simplest way is to simply reassign:
Cheese swiss("Jarlsberg", 4.99);
...
swiss = Cheese("Gruyère",5.99);
This may require you to execute the assignment operator, but according to the rules of three or five options, you still have to do this (but the assignment operator is not needed if you follow the zero rule ).
, swiss:
Cheese* swiss = new Cheese("Jarlsberg", 4.99);
...
delete swiss;
swiss = new Cheese("Gruyère",5.99);
- , , ++. ( ) , . , , , , , .
, , , , , :
Cheese swiss("Jarlsberg", 4.99);
...
{
Cheese swiss("Gruyère",5.99);
...
}
, , , , , . , () , , jarlsberg gruyere, gruyere , , "".