Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- main.h
- =================
- #include <iostream>
- #include <map>
- enum
- {
- weapon,
- ammo,
- food
- };
- class c_items
- {
- bool operator()(const c_items& l, const c_items& r) const
- {
- return (l.id < r.id);
- }
- public:
- c_items(void){};
- c_items(int id, char name[], int type, double weight);
- char *name;
- int type;
- double weight;
- int id;
- };
- extern std::map<int,c_items> Stuff;
- c_items::c_items(int id, char name[], int type, double weight) : id(id), type(type), name(name), weight(weight)
- {
- Stuff[id] = *this;
- }
- extern c_items
- brass_knuckles,
- golf_club;
- =================
- main.cpp
- =================
- #include "main.h"
- std::map<int,c_items> Stuff;
- c_items
- brass_knuckles (1, "Brass knuckles", weapon, 0.1),
- golf_club (2, "Gold club", weapon, 0.8);
- using namespace std;
- int main()
- {
- cout << Stuff[1].name << endl;
- cout << golf_club.name;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement