I am trying to write a short RPG like program to teach myself C++. I would only like the program to allow the user to by items (sword, shield, etc.) from a store and add them to their list of items. I'd also like for these items to be objects of a class so that I can give them data members such as name and price. But I can't figure out how to put objects into something like a vector or an array. Is there a way to do that? Or is there some other way?
jobluz06
0
Newbie Poster
Recommended Answers
Jump to PostYou want the user to be able to buy items. (You accidentally misspelled that.)
Your best bet is to use one of the STL collection classes with a base item type.
That is, create an abstract class for your items, and derive specific items from it. Then use …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.