inventory system into a header file

hey guys, im working on a inventory system for a txt based rpg and i have a system but it's in the main function... what i want to do is put it into its own.cpp and then declare the variables in a header because there's me and 2 other people working on it... so that way we can combine our codes w/o any hassle this is my code if someone could help me out it would be greatly appreciated

thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RPG inventory
// 17/08/2010
// BLACKOU7 GAMEZ

#include "../../std_lib_facilities.h"
using namespace std;

int main()
{
	vector<string> inventory;
	inventory.push_back("sword");
	inventory.push_back("armor");
	inventory.push_back("shield");
	inventory.push_back("health");
	inventory.push_back("bow_arrow");
	inventory.push_back("magic_staff");
	//inventory.push_back("battle_axe");
	inventory.push_back("torchlight");

	vector<string>::iterator myIterator;
	vector<string>::const_iterator iter;

	cout << "Your Items\n";
	for(iter = inventory.begin(); iter != inventory.end(); ++iter)
		cout << *iter << endl;

	cout << "Trade Sword for a Battle Axe:";
	myIterator = inventory.begin();
	*myIterator = "battle axe";
	cout << "\nYour items:\n";
	for(iter = inventory.begin(); iter != inventory.end(); ++iter)
		cout << *iter << endl;

	cout << "\nThe item name '" << *myIterator << " has ";
	cout << (*myIterator).size() << " Letters in it .\n";
	cout << myIterator->size() << "letters in it.\n";

	cout << "\nYou Recover a crossbow from a slain enemy,";
	inventory.insert(inventory.begin(), "crossbow");
	cout <<"\nYour Items\n";
	for(iter = inventory.begin(); iter != inventory.end(); ++iter)
		cout << *iter << endl;

	cout <<"\nYour armor is destroyed in a fierce battle.";
	inventory.erase((inventory.begin() + 2));
	cout << "\nYour items:\n";
	for(iter = inventory.begin(); iter != inventory.end(); ++iter)
		cout << *iter << endl;

	return 0;
}
this isnt fully complete yet its just a rough thing i coded to see how i was going to incorporate the story.

and what i dont get is how i'm going to call this in my main function... :s
Last edited on
anyone.......?
Do You mind creating an inventory class?... (declarations in the header, definitions in the cpp)...

To be honest: I donĀ“t fully understand your question...

Why would you just push back random stuff into the inventor just to enumerate them? (I know that is not what You want to do, but to make sure You understand what I may intend)...
yeah i can make it into a class i just want it to work.
w/o having to copy my partners codes into mine and take a chance of having a bunch of errors i just thought i would do it this way to make things easier... but if you have a easier method than by all means i'm willing to make adjustments
Topic archived. No new replies allowed.