Click here to Skip to main content
15,912,072 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Requestion(some changes ) Pin
David Crow27-Aug-08 3:28
David Crow27-Aug-08 3:28 
QuestionCreateProcess() method Pin
Madan Chauhan26-Aug-08 20:02
Madan Chauhan26-Aug-08 20:02 
AnswerRe: CreateProcess() method Pin
Nibu babu thomas26-Aug-08 20:08
Nibu babu thomas26-Aug-08 20:08 
AnswerRe: CreateProcess() method Pin
Jijo.Raj26-Aug-08 20:30
Jijo.Raj26-Aug-08 20:30 
Question[Message Deleted] Pin
ptr_Electron26-Aug-08 19:16
ptr_Electron26-Aug-08 19:16 
AnswerRe: Application crash before the window is displayed Pin
Nibu babu thomas26-Aug-08 19:36
Nibu babu thomas26-Aug-08 19:36 
QuestionRich Edit control Highlight selection color problem Pin
riteshsv26-Aug-08 19:13
riteshsv26-Aug-08 19:13 
QuestionSTL map issue Pin
George_George26-Aug-08 17:31
George_George26-Aug-08 17:31 
Hello everyone,


My question is about how many instances' copies are made when inserting new elements into map. Here is my code and questions.

1.

I think when not using pair, there will be one instance copied, from string instance named MikeName to the int key "1" related string instance in the map, and map maintains a separate indepenent copy of string instance from MikeName other than just making a reference to DavidName?

2.

And using pair will make one additional instance copy, from from string instance named MikeName to pair (pair will maintain a separate instance other than just making a reference), and from pair to string instance in the map.

#include <string>
#include <iostream>
#include <map>
#include <utility>

using namespace std;

int main()
{
   string MikeName = "Mike";
   string DavidName = "David";

   map<int, string> Employees;

   Employees[1] = MikeName;

   pair<int, string> p(2, DavidName);
   Employees.insert(p);

   return 0;
}



thanks in advance,
George
AnswerRe: STL map issue Pin
Nibu babu thomas26-Aug-08 19:11
Nibu babu thomas26-Aug-08 19:11 
GeneralRe: STL map issue Pin
George_George26-Aug-08 19:41
George_George26-Aug-08 19:41 
GeneralRe: STL map issue Pin
Nibu babu thomas26-Aug-08 19:58
Nibu babu thomas26-Aug-08 19:58 
GeneralRe: STL map issue Pin
George_George26-Aug-08 23:26
George_George26-Aug-08 23:26 
GeneralRe: STL map issue Pin
Nibu babu thomas26-Aug-08 23:32
Nibu babu thomas26-Aug-08 23:32 
GeneralRe: STL map issue Pin
George_George26-Aug-08 23:34
George_George26-Aug-08 23:34 
GeneralRe: STL map issue Pin
Nibu babu thomas26-Aug-08 23:50
Nibu babu thomas26-Aug-08 23:50 
GeneralRe: STL map issue Pin
George_George27-Aug-08 1:58
George_George27-Aug-08 1:58 
QuestionRPC Client Pin
sunny_vc26-Aug-08 15:44
sunny_vc26-Aug-08 15:44 
AnswerRe: RPC Client Pin
Garth J Lancaster26-Aug-08 17:00
professionalGarth J Lancaster26-Aug-08 17:00 
GeneralRe: RPC Client Pin
sunny_vc27-Aug-08 21:25
sunny_vc27-Aug-08 21:25 
QuestionLimit for vector????? Pin
TooShy2Talk26-Aug-08 15:29
TooShy2Talk26-Aug-08 15:29 
AnswerRe: Limit for vector????? Pin
Nibu babu thomas26-Aug-08 19:06
Nibu babu thomas26-Aug-08 19:06 
QuestionCMFCRibbonButton / CMFCRibbonBaseElement Pin
bigcivilmelon26-Aug-08 13:11
bigcivilmelon26-Aug-08 13:11 
QuestionNeed help to pass float or Double argument with _begintherad() Pin
smdhd26-Aug-08 12:41
smdhd26-Aug-08 12:41 
AnswerRe: Need help to pass float or Double argument with _begintherad() Pin
Rick York26-Aug-08 13:11
mveRick York26-Aug-08 13:11 
AnswerRe: Need help to pass float or Double argument with _begintherad() Pin
Mark Salsbery27-Aug-08 6:59
Mark Salsbery27-Aug-08 6:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.