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

C / C++ / MFC

 
Questionmemory leak Pin
SRKSHOME28-Sep-08 20:42
SRKSHOME28-Sep-08 20:42 
AnswerRe: memory leak Pin
Sauce!28-Sep-08 21:09
Sauce!28-Sep-08 21:09 
GeneralRe: memory leak [modified] Pin
SRKSHOME28-Sep-08 21:23
SRKSHOME28-Sep-08 21:23 
GeneralRe: memory leak Pin
Sauce!29-Sep-08 18:07
Sauce!29-Sep-08 18:07 
GeneralRe: memory leak Pin
SRKSHOME29-Sep-08 18:24
SRKSHOME29-Sep-08 18:24 
AnswerRe: memory leak Pin
KarstenK28-Sep-08 21:16
mveKarstenK28-Sep-08 21:16 
AnswerRe: memory leak Pin
_AnsHUMAN_ 28-Sep-08 21:19
_AnsHUMAN_ 28-Sep-08 21:19 
AnswerRe: memory leak Pin
Saurabh.Garg28-Sep-08 21:21
Saurabh.Garg28-Sep-08 21:21 
There are two bugs in this program:

1. test1->(new test(20)); // This is incorrect. Perhaps you mean test1->display(new test(20));
2. You are using test1 without allocating memory for it.

You can try something like this:

test* test1 = new test;
test* test2 = new test;
test1->display(test2);
delete test1;
delete test2;

Or

test test1;<br />
test test2;<br />
test1.display(&test2);


-Saurabh
QuestionArray Size Pin
TeVc++28-Sep-08 20:19
TeVc++28-Sep-08 20:19 
AnswerRe: Array Size Pin
MANISH RASTOGI28-Sep-08 20:33
MANISH RASTOGI28-Sep-08 20:33 
GeneralRe: Array Size Pin
TeVc++28-Sep-08 20:43
TeVc++28-Sep-08 20:43 
GeneralRe: Array Size Pin
MANISH RASTOGI30-Sep-08 18:25
MANISH RASTOGI30-Sep-08 18:25 
AnswerRe: Array Size Pin
ThatsAlok28-Sep-08 20:37
ThatsAlok28-Sep-08 20:37 
GeneralRe: Array Size Pin
TeVc++28-Sep-08 20:52
TeVc++28-Sep-08 20:52 
GeneralRe: Array Size Pin
Sauce!28-Sep-08 21:00
Sauce!28-Sep-08 21:00 
GeneralRe: Array Size Pin
santhoshv8428-Sep-08 21:10
santhoshv8428-Sep-08 21:10 
AnswerRe: Array Size Pin
KarstenK28-Sep-08 21:18
mveKarstenK28-Sep-08 21:18 
QuestionRe: Array Size Pin
CPallini28-Sep-08 21:45
mveCPallini28-Sep-08 21:45 
AnswerRe: Array Size Pin
TeVc++28-Sep-08 22:14
TeVc++28-Sep-08 22:14 
GeneralRe: Array Size Pin
CPallini28-Sep-08 22:24
mveCPallini28-Sep-08 22:24 
GeneralRe: Array Size Pin
TeVc++28-Sep-08 23:25
TeVc++28-Sep-08 23:25 
QuestionRe: Array Size Pin
CPallini28-Sep-08 23:35
mveCPallini28-Sep-08 23:35 
AnswerRe: Array Size Pin
TeVc++28-Sep-08 23:49
TeVc++28-Sep-08 23:49 
GeneralRe: Array Size Pin
CPallini29-Sep-08 0:15
mveCPallini29-Sep-08 0:15 
GeneralRe: Array Size Pin
TeVc++29-Sep-08 0:32
TeVc++29-Sep-08 0:32 

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.