Quantcast
Channel: Questions in topic: "item"
Viewing all articles
Browse latest Browse all 274

Calling a constructor in a class with multiple constructors

$
0
0
Hello, I'm working on an Item system where I can create Weapons, Armors, and Consumables. The "Item" class contains three constructors for creating weapons, armors and consuambles. Item class: ![alt text][1] My issue is that whenever I call for example the weapon creation constructor of the Item class, seen in this image, for some reason all three constructors are called, even though I just put the Weapon type as the parameter: ![alt text][2] As you can see, the Item type, which is "Element 0" in the image below, for some reason got called on everyone of its constructors, even though I only called "new Item(new Weapon())", so only calling the weapon constructor. I do not want an element with all three weapon, armor and consumables, i currently only want weapons. How do I only call one of the constructors, for example the Weapon constructor in the Item class? Appreciate the help! :) [1]: /storage/temp/101448-unknown.png [2]: /storage/temp/101451-udklip.png

Viewing all articles
Browse latest Browse all 274

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>