I am writing a console game and i've spent more time copying initializer list contents than i have actually writing code, is there an easier way to do this? What happens if i have hundreds of functions? It seems like there has to be an easier way, I have to copy all the contents of one initializer list to anohter and then i have to do the prototype initializer list. also what if i have hundreds of classes? I have to type all that into the lists and the prototypes? Is there an easier way?
A function can be treated as an abstract operation over some operands. The minimal definition for a "shop" operation only requires to know who is buying and who is selling. So the signature might be Player::Shop(NPC &). Let's suppose that Player::Shop() doesn't return until the user leaves the "buy" dialog box, which displays various items that can be purchased.
Inside Player::Shop(), there may be calls at various points to a function that performs a single transaction between the two parties, such as Player::Buy(NPC &, ObjectID &, int quantity). This function will modify the inventory of the two parties accordingly, removing or adding the specified number of a specific kind of item, as well as change the amount of money the parties have.