Click here to Skip to main content
15,910,980 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionRe: [C] Multithreading in windows Pin
Newbie0025-Feb-07 3:41
Newbie0025-Feb-07 3:41 
AnswerRe: [C] Multithreading in windows Pin
venetus25-Feb-07 3:43
venetus25-Feb-07 3:43 
GeneralRe: [C] Multithreading in windows Pin
Newbie0025-Feb-07 3:50
Newbie0025-Feb-07 3:50 
GeneralRe: [C] Multithreading in windows Pin
Christian Graus25-Feb-07 9:11
protectorChristian Graus25-Feb-07 9:11 
Question[API] Add a dll Pin
abbd24-Feb-07 4:55
abbd24-Feb-07 4:55 
AnswerRe: [API] Add a dll Pin
Christian Graus24-Feb-07 16:26
protectorChristian Graus24-Feb-07 16:26 
QuestionCopy constructor Pin
Karismatic23-Feb-07 17:09
Karismatic23-Feb-07 17:09 
AnswerRe: Copy constructor Pin
prasad_som24-Feb-07 5:25
prasad_som24-Feb-07 5:25 
pan_angel wrote:
where it is mandatory to define copy construc


It is not mandateroy to define copy c'to. But, it is required to define in cases where, one of member variable is pointer and uses dynamic memory allocation.
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
   m_pName = new char [strlen(pName)+1]  ;
   strcpy(m_pName,pName);
   nid = nId;
}
~A()
{
delete []m_pName;
m_pName = NULL;
}
};
int main()
{
  A aObj("Prasad",1);
  A aObj1 = aObj;//this will work, but its not safe as m_pName  of aObj1 become unusable once aObj is destroyed , 
//default copy s'tor does shallow copy
}

So should modify your defintion to,
class A
{
char *m_pName;
int m_nid;
public:
A(char *pName,int nId)
{
   m_pName = new char [strlen(pName)+1]  ;
   strcpy(m_pName,pName);
   m_nid = nId;
}
A(A& aObj)
{
   int  nMemoryToAlloacate = strlen(aObj's char pointer);
   m_pName = new char [nMemoryToAlloacate + 1]  ;
   strcpy(m_pName,aObj's char pointer);
   m_nid = aObj's m_nid ;
}

~A()
{
delete []m_pName;
m_pName = NULL;
}
};



AnswerRe: Copy constructor [modified] Pin
Paresh Chitte26-Feb-07 17:28
Paresh Chitte26-Feb-07 17:28 
AnswerRe: Copy constructor Pin
Christian Graus24-Feb-07 16:27
protectorChristian Graus24-Feb-07 16:27 
QuestionCreating a Observer between managed and unmanaged Code Pin
ismare22-Feb-07 0:58
ismare22-Feb-07 0:58 
AnswerRe: Creating a Observer between managed and unmanaged Code Pin
User 58385222-Feb-07 13:30
User 58385222-Feb-07 13:30 
GeneralRe: Creating a Observer between managed and unmanaged Code Pin
ismare24-Feb-07 2:51
ismare24-Feb-07 2:51 
QuestionLNK1104: cannot open file Pin
vandelaycp21-Feb-07 11:01
vandelaycp21-Feb-07 11:01 
AnswerRe: LNK1104: cannot open file Pin
Christian Graus21-Feb-07 11:32
protectorChristian Graus21-Feb-07 11:32 
GeneralRe: LNK1104: cannot open file Pin
vandelaycp21-Feb-07 14:32
vandelaycp21-Feb-07 14:32 
AnswerRe: LNK1104: cannot open file Pin
Hamid_RT1-Mar-07 6:52
Hamid_RT1-Mar-07 6:52 
QuestionRWCString limit (max size) - Rogue Wave. Pin
mdosi21-Feb-07 7:46
mdosi21-Feb-07 7:46 
AnswerRe: RWCString limit (max size) - Rogue Wave. Pin
Christian Graus21-Feb-07 11:33
protectorChristian Graus21-Feb-07 11:33 
GeneralRe: RWCString limit (max size) - Rogue Wave. Pin
mdosi21-Feb-07 11:38
mdosi21-Feb-07 11:38 
GeneralRe: RWCString limit (max size) - Rogue Wave. Pin
Christian Graus21-Feb-07 19:09
protectorChristian Graus21-Feb-07 19:09 
QuestionUnmanaged in manage Pin
ThatsAlok21-Feb-07 6:18
ThatsAlok21-Feb-07 6:18 
AnswerRe: Unmanaged in manage Pin
led mike21-Feb-07 8:01
led mike21-Feb-07 8:01 
GeneralRe: Unmanaged in manage Pin
ThatsAlok21-Feb-07 18:43
ThatsAlok21-Feb-07 18:43 
GeneralRe: Unmanaged in manage Pin
led mike22-Feb-07 4:42
led mike22-Feb-07 4:42 

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.