Click here to Skip to main content
16,005,169 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: std::vector fails?! Pin
Giles19-Oct-02 4:26
Giles19-Oct-02 4:26 
GeneralRe: std::vector fails?! Pin
Neville Franks19-Oct-02 12:57
Neville Franks19-Oct-02 12:57 
GeneralRe: std::vector fails?! Pin
Chris Losinger19-Oct-02 5:07
professionalChris Losinger19-Oct-02 5:07 
GeneralRe: std::vector fails?! Pin
Anonymous19-Oct-02 9:10
Anonymous19-Oct-02 9:10 
GeneralRe: std::vector fails?! Pin
Chris Losinger19-Oct-02 9:17
professionalChris Losinger19-Oct-02 9:17 
GeneralRe: std::vector fails?! Pin
Anonymous19-Oct-02 9:47
Anonymous19-Oct-02 9:47 
GeneralRe: std::vector fails?! Pin
Chris Losinger19-Oct-02 9:53
professionalChris Losinger19-Oct-02 9:53 
GeneralRe: std::vector fails?! Pin
Anonymous19-Oct-02 10:00
Anonymous19-Oct-02 10:00 
Chris Losinger wrote:
sure, but that won't fix the problem of CBitmaps deleting their contents.


yes, and thanks for pointing this out.

May I ask what I don't understand:
Why is there no copy ctor in CBitmap?

A copy ctor would normaly copy the CBitmap object to another object
before the dtor is called. You can visualize this:

#include <stdio.h>
#include <vector>

//testd.cpp : playing with vector and visualize copy/moving of elements

class testme 
{
public:
  testme() { 
    value = 0;
    printf("testme ctor      (%d,0x%X)\n", value, (unsigned int) this); 
  }
 testme(int t) { 
    value = t;
    printf("testme ctor      (%d,0x%X)\n", value, (unsigned int) this); 
  }
  testme(const testme& ref) { 
    value = ref.value; 
    /* copy more stuff here */
    printf("testme copy ctor (%d,0x%X <- 0x%X)\n", value, (unsigned int) this, (unsigned int) &ref);  
  }
  ~testme() { 
    printf("testme dtor      (%d, 0x%X)\n", value, (unsigned int) this); 
  }
  testme& operator= (const testme &ref) { 
     value = ref.value;
     /* copy more stuff here */
     printf("testme assigning  %d,0x%X <- 0x%X\n", value, (unsigned int) this, (unsigned int) &ref); 
     return *this; 
  }

private:
  int value;
};

int main() 
{
  std::vector<testme> v;
  v.reserve(3);

  testme test1(1); 
  testme test2(2);
  testme test3(3);

  printf("push_back\n");
  v.push_back(test1);
  v.push_back(test2);
  v.push_back(test3);

  printf("erase first\n"); 
  v.erase(v.begin());

  v.clear();
}


Output from above:

testme ctor      (1,0xBFFFF55C)
testme ctor      (2,0xBFFFF558)
testme ctor      (3,0xBFFFF554)
push_back
testme copy ctor (1,0x804C340 <- 0xBFFFF55C)
testme copy ctor (2,0x804C344 <- 0xBFFFF558)
testme copy ctor (3,0x804C348 <- 0xBFFFF554)
erase first
testme assigning  2,0x804C340 <- 0x804C344
testme assigning  3,0x804C344 <- 0x804C348
testme dtor      (3, 0x804C348)
testme dtor      (2, 0x804C340)
testme dtor      (3, 0x804C344)
testme dtor      (3, 0xBFFFF554)
testme dtor      (2, 0xBFFFF558)
testme dtor      (1, 0xBFFFF55C)

GeneralRe: std::vector fails?! Pin
Chris Losinger19-Oct-02 10:09
professionalChris Losinger19-Oct-02 10:09 
GeneralRe: std::vector fails?! duplicate a HBITMAP? Pin
Anonymous19-Oct-02 10:25
Anonymous19-Oct-02 10:25 
GeneralRe: std::vector fails?! duplicate a HBITMAP? Pin
Chris Losinger19-Oct-02 10:37
professionalChris Losinger19-Oct-02 10:37 
GeneralRe: std::vector fails?! duplicate a HBITMAP? Pin
Anonymous19-Oct-02 10:48
Anonymous19-Oct-02 10:48 
GeneralRe: std::vector fails?! - Don't use auto_ptr Pin
Neville Franks19-Oct-02 13:10
Neville Franks19-Oct-02 13:10 
GeneralRe: std::vector fails?! - Don't use auto_ptr Pin
Anonymous19-Oct-02 14:11
Anonymous19-Oct-02 14:11 
GeneralRe: std::vector fails?! - Don't use auto_ptr Pin
Chris Losinger19-Oct-02 15:32
professionalChris Losinger19-Oct-02 15:32 
GeneralRe: std::vector fails?! - Don't use auto_ptr Pin
Neville Franks19-Oct-02 16:01
Neville Franks19-Oct-02 16:01 
GeneralRe: std::vector fails?! - Don't use auto_ptr Pin
Anonymous19-Oct-02 21:35
Anonymous19-Oct-02 21:35 
GeneralRe: std::vector fails?! Pin
Anonymous19-Oct-02 9:26
Anonymous19-Oct-02 9:26 
QuestionHow to make "Enter" key work like a "Tab" key in a Dialog box? Pin
Seagull Livingston18-Oct-02 21:18
Seagull Livingston18-Oct-02 21:18 
AnswerRe: How to make "Enter" key work like a "Tab" key in a Dialog box? Pin
Stephane Rodriguez.18-Oct-02 21:47
Stephane Rodriguez.18-Oct-02 21:47 
AnswerRe: How to make "Enter" key work like a "Tab" key in a Dialog box? Pin
Nish Nishant18-Oct-02 23:39
sitebuilderNish Nishant18-Oct-02 23:39 
GeneralCListCtrl & Double Click :: MFC Pin
valikac18-Oct-02 20:55
valikac18-Oct-02 20:55 
GeneralRe: CListCtrl & Double Click :: MFC Pin
Stephane Rodriguez.18-Oct-02 21:10
Stephane Rodriguez.18-Oct-02 21:10 
GeneralRe: CListCtrl & Double Click :: MFC Pin
valikac18-Oct-02 21:38
valikac18-Oct-02 21:38 
GeneralRe: CListCtrl & Double Click :: MFC Pin
Stephane Rodriguez.18-Oct-02 21:46
Stephane Rodriguez.18-Oct-02 21:46 

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.