Click here to Skip to main content
15,894,405 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 5:31
Iain Clarke, Warrior Programmer30-Sep-08 5:31 
GeneralRe: dynamic allocation of arrays Pin
Sauce!30-Sep-08 5:43
Sauce!30-Sep-08 5:43 
GeneralRe: dynamic allocation of arrays Pin
Iain Clarke, Warrior Programmer30-Sep-08 6:02
Iain Clarke, Warrior Programmer30-Sep-08 6:02 
GeneralRe: dynamic allocation of arrays Pin
Sauce!2-Oct-08 5:05
Sauce!2-Oct-08 5:05 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 2:42
Sauce!4-Oct-08 2:42 
GeneralRe: dynamic allocation of arrays Pin
Sauce!4-Oct-08 5:19
Sauce!4-Oct-08 5:19 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 5:34
Sauce!4-Oct-08 5:34 
GeneralRe: dynamic allocation of arrays [modified] Pin
Sauce!4-Oct-08 12:53
Sauce!4-Oct-08 12:53 
Okay so now I've built the copy constructor and I'm fairly certain it works perfectly, however now when I step through the program, The constructor for Block is being called once, followed by it's destructor, which now exhibits normal behaviour, first deleting p_TileArray and then setting it to NULL. Then the constructor is being called a second time, once again followed by the destructor, which also exhibits normal behaviour, but THEN the destructor is called a second time without another call to the constructor, which ends with a Debug assertion failure Frown | :(

EDIT:
for(int i=0; i < 10; i++)<br />
{<br />
Block theBlock;	<br />
vector_BlockList.push_back(theBlock);<br />
p_CurrentBlock = &vector_BlockList.back();<br />
}


After the second iteration of this loop, vector_BlockList contains two of my Block class. The watch window tells me that the member variables are:

vector_BlockList[0].Shape = 5
vector_BlockList[0].Colour = 2
vector_BlockList[0].Grounded = false
vector_BlockList[0].p_TileArray = 0x00d15c7c {left=-1.5883997e+038 top=-1.5883997e+038 depth=-1.5883997e+038 ...} //p_TileArray has lost it's value after being inserted into the List.

vector_BlockList[1].Shape = 1
vector_BlockList[1].Colour = 4
vector_BlockList[1].Grounded = false
vector_BlockList[1].p_TileArray = p_TileArray = 0x00d15c7c {left=-1.5883997e+038 top=-1.5883997e+038 depth=-1.5883997e+038 ...} //Contains the same memory as vector_BlockList[0].p_TileArray - why?


modified on Saturday, October 4, 2008 7:18 PM

GeneralRe: dynamic allocation of arrays Pin
Sauce!17-Oct-08 20:58
Sauce!17-Oct-08 20:58 
Questionno WM_MOUSEHOVER in an edit Pin
followait28-Sep-08 18:58
followait28-Sep-08 18:58 
AnswerRe: no WM_MOUSEHOVER in an edit Pin
Iain Clarke, Warrior Programmer30-Sep-08 0:25
Iain Clarke, Warrior Programmer30-Sep-08 0:25 
QuestionCListCtrl Problem Pin
Dhiraj kumar Saini28-Sep-08 18:53
Dhiraj kumar Saini28-Sep-08 18:53 
AnswerRe: CListCtrl Problem Pin
_AnsHUMAN_ 28-Sep-08 18:59
_AnsHUMAN_ 28-Sep-08 18:59 
AnswerRe: CListCtrl Problem Pin
Naveen28-Sep-08 19:01
Naveen28-Sep-08 19:01 
QuestionWrite a buffer to stringstream Pin
CodingLover28-Sep-08 18:43
CodingLover28-Sep-08 18:43 
AnswerRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:04
Naveen28-Sep-08 19:04 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:08
CodingLover28-Sep-08 19:08 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:26
Naveen28-Sep-08 19:26 
NewsRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 19:35
CodingLover28-Sep-08 19:35 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 19:54
Naveen28-Sep-08 19:54 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 20:18
CodingLover28-Sep-08 20:18 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 20:29
Naveen28-Sep-08 20:29 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 20:36
CodingLover28-Sep-08 20:36 
GeneralRe: Write a buffer to stringstream Pin
Naveen28-Sep-08 21:25
Naveen28-Sep-08 21:25 
GeneralRe: Write a buffer to stringstream Pin
CodingLover28-Sep-08 22:44
CodingLover28-Sep-08 22:44 

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.