|
-
June 18th, 2012, 12:03 AM
#1
How to insert and retrive an object without default ctor from container?
Hi,
I have a third party class object, CPP_OBJECT that i save in std container.
for example; i want to do the following.
std::map<std::string, CPP_OBJECT> mymap;
mymap["test"]= myobj;
mymap.insert["test",myobject];//This doesn't work!!
Now that I have created the CPP_OBJECT and save it to the map.
i want to retrieve the CPP_OBJECT from the map using a std::string ID later.
CPP_OBJECT l_object = mymap["test"];
apparent i can't do as ablve as the CPP_OBJECT does't have a default ctor.
CPP_OBJECT *l_object = &mymap["test"]; //this result in error "no default constructor available" in CPP_OBJECT,
Can anyone help me on this??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|