Let's create a new weapon object by copying huntingBow into a new variable, and updating its data to see whether the changes affect both structs:
- Declare a new Weapon struct in LearningCurve, and assign huntingBow as its initial value:
Weapon huntingBow = new Weapon("Hunting Bow", 105);
Weapon warBow = huntingBow;
- Print out each weapon's data using the debug method:
huntingBow.PrintWeaponStats();
warBow.PrintWeaponStats();
- The way they're set up now, both huntingBow and warBow will have the same debug logs, just like our two characters did before we changed any data:
- Change the warBow.name and warBow.damage fields to values of your choice and click on Play again:
Weapon warBow = huntingBow;
warBow.name = "War Bow";
warBow.damage = 155;
The console will show that only the data relating to warBow was changed, and that huntingBow retains...