L
L
LittleFatNinja2015-04-01 15:38:13
Programming
LittleFatNinja, 2015-04-01 15:38:13

Why can I create a map with my class without overloading operator

there is a class

class Item {
private:
  string name;
  int price;
  Category *category;

public:
  Item( ... );
  ~Item();
  //code
};

in the order class I create a map with Items
class Order {
private:
  static int number;
  Customer *const customer;
  map<Item*, int> *items;

public:
  Order( ... );
  ~Order();
  //code
};

in the Order constructor
items = new map<Item*, int>;
  items->insert(std::pair<Item*, int>(item, 1));

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iv_k, 2015-04-01
@LittleFatNinja

because your key is a pointer

J
jcmvbkbc, 2015-04-01
@jcmvbkbc

Why works map with my class without define operator

Why write English without knowing which one?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question