explosiv | JSX-powered static site generator for Node.js | Static Site Generator library
kandi X-RAY | explosiv Summary
kandi X-RAY | explosiv Summary
A fork of the already beautiful Dhow. A simple and powerful JSX Static Site Generator.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of explosiv
explosiv Key Features
explosiv Examples and Code Snippets
Community Discussions
Trending Discussions on explosiv
QUESTION
I'm messing around with C++ by making a console game. I have a superclass called "WeaponType." Within this class is a static method that creates all of the types of weapons that I'll need. The child class "Weapon" will inherit from WeaponType. (I'm new to inheritance, so forgive my ignorance in advance.)
The way I see the code now, I'll have to declare a new instance of the WeaponType superclass every time I create an instance of the Weapon subclass. This is a problem because I don't want to create any more instances of the WeaponType superclass that are all initialized on the HEAP in the static method that creates them.
I'm either looking for a way to delete every new instance of the WeaponType superclass after doing what I need to with the object. (For example, if make another instance of WeaponType that specifies it's supposed to be the "melee" object and I have already created an instance called "melee", I want to be able to "migrate" the WeaponType to the original object and delete the new object).
The code I have is not complete, but you should be able to get the idea of what I want.
Here's most of the code for WeaponType:
...ANSWER
Answered 2019-Sep-15 at 09:51From my understanding, you're using WeaponType to store all the characteristics, whereas a Weapon represents an actual object in the game, so it has a type but it also has things like ammo or a position in the world and things like this.
Instead of modelling this relationship as Weapon is-a WeaponType, consider modelling it as a Weapon has-a WeaponType. Cutting down your linked code to something reasonable, an approach like this might be better:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install explosiv
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page