About Store Forum Documentation Contact



Post Reply 
Map insert without create
Author Message
Lancer Offline
Member

Post: #1
Map insert without create
Hello,

is there a way to use EE::Map without having to create a new object each time I wanna insert something?

As example map.insert(key, object);

The reason for that:
I have multiple classes and 1 base class.

Example:
class a : base
class b : base
class c : base

and I want to store these classes in the same map. But the map would only create "base" and not the real class.

Regards
02-16-2019 09:53 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Map insert without create
Map can support only 1 type of class.

To have multiple classes, one option is to store a pointer:

Map<Key, Base*> map;
*map(key)=new a;

But that's not optimal.
02-17-2019 05:09 AM
Find all posts by this user Quote this message in a reply
Post Reply