Click here to Skip to main content

C / C++ / MFC

 
GeneralRe: How to set the alignment of items of CListCtrl Pinmemberrahul.kulshreshtha20-Nov-12 17:30 
GeneralRe: How to set the alignment of items of CListCtrl PinmvpRichard MacCutchan20-Nov-12 22:17 
QuestionLinked Lists and unique_ptr's PinmemberTom Moore19-Nov-12 8:29 
AnswerRe: Linked Lists and unique_ptr's [modified] PinmemberEugen Podsypalnikov19-Nov-12 11:50 
Hm... Try it Smile | :) :
  node a(3); // a, will be deleted as a stack variable
  a.next = new node(4); // b, will be deleted by unique_ptr of a
  a.next->next = new node(5); // c, will be deleted by unique_ptr of b
  // 1. deleting of b, not "tested" :) :
  a.next = move(a.next->next); // is there a crash ?
  // 2. then deleting of b, old style :) :
  unique_ptr<node> temp = move(a.next->next);
  a.next = move(temp);
 
PS: any pre 0x11 C++ strcture or class may have a destructor as well :
struct node {
  int m_iData;
  node* m_pNext;
 
  node(int iData) : m_iData(iData), m_pNext(NULL) {}
  ~node() { delete m_pNext; }
 
  node* detach() { node* prevNext(m_pNext); m_pNext = NULL; return prevNext; }
} a(3);
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap. Smile | :)


modified 19-Nov-12 17:07pm.

AnswerRe: Linked Lists and unique_ptr's PinmemberChris Meech19-Nov-12 15:04 
Questionencrypt and decrypt Pinmemberthandy mitchell19-Nov-12 7:24 
AnswerRe: encrypt and decrypt PinmvpRichard MacCutchan19-Nov-12 8:59 
AnswerRe: encrypt and decrypt PinmvpCPallini19-Nov-12 12:36 
Questionaccess excel data using c++ Pinmemberlakshmamma19-Nov-12 3:05 
AnswerRe: access excel data using c++ PinmemberFlaviu219-Nov-12 3:14 

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

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


Advertise | Privacy | Mobile
Web04 | 2.8.150327.1 | Last Updated 31 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid