Click here to Skip to main content
15,915,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Question3D Image Pin
ashwath197914-Jan-10 1:18
ashwath197914-Jan-10 1:18 
AnswerCross Post ! Pin
Garth J Lancaster14-Jan-10 1:33
professionalGarth J Lancaster14-Jan-10 1:33 
Questionerror: hres 0x80010106 Cannot change thread mode after it is set. Pin
Le@rner13-Jan-10 23:28
Le@rner13-Jan-10 23:28 
AnswerRe: error: hres 0x80010106 Cannot change thread mode after it is set. Pin
Richard MacCutchan14-Jan-10 0:45
mveRichard MacCutchan14-Jan-10 0:45 
GeneralRe: error: hres 0x80010106 Cannot change thread mode after it is set. Pin
CPallini14-Jan-10 1:58
mveCPallini14-Jan-10 1:58 
GeneralRe: error: hres 0x80010106 Cannot change thread mode after it is set. Pin
Richard MacCutchan14-Jan-10 4:43
mveRichard MacCutchan14-Jan-10 4:43 
QuestionCDockablePane AutHide issue Pin
Harsh Shankar13-Jan-10 22:58
Harsh Shankar13-Jan-10 22:58 
QuestionC++ - Virtual Destructor Pin
davarun13-Jan-10 21:49
davarun13-Jan-10 21:49 
Hi,

Have a doubt, will virtual destructor work only when u create objects thru heap ??? Bcoz the following code works either way with or without virtual destructor .


class A
{
int *p;
public :
A() {p = new int;
*p = 10;}
~A ()
{
delete p;
p = NULL;
printf("this is A dest \n");
}

virtual int getVal()
{
if(p)
return *p;
return 0;
}
};

class B : public A
{
int *p1;
public :
B() {
p1 = new int;
*p1 = 10;
printf("this is B dest \n");
}
~B ()
{
delete p1;
p1 = NULL;
}

int getVal()
{
if(p1)
return *p1;
return 0;
}
};


int main(int argc, char* argv[])
{
B b;
A *ap = &b;
ap->getVal();

//But virtual destructor works when u do thru heap
//B *pb = new B;
//A *ap = new B;
//delete pb;
//delete ap;
return 0;
}

Here when objects goes out of scope , both destructors getting called irrespecive of virtual. So virtual destructor works only with heap ?
AnswerRe: C++ - Virtual Destructor Pin
CPallini13-Jan-10 22:31
mveCPallini13-Jan-10 22:31 
AnswerRe: C++ - Virtual Destructor Pin
Graham Breach13-Jan-10 22:37
Graham Breach13-Jan-10 22:37 
AnswerRe: C++ - Virtual Destructor Pin
Stuart Dootson13-Jan-10 23:27
professionalStuart Dootson13-Jan-10 23:27 
GeneralRe: C++ - Virtual Destructor Pin
davarun15-Jan-10 2:36
davarun15-Jan-10 2:36 
GeneralRe: C++ - Virtual Destructor Pin
Stuart Dootson15-Jan-10 2:58
professionalStuart Dootson15-Jan-10 2:58 
GeneralRe: C++ - Virtual Destructor Pin
davarun15-Jan-10 3:23
davarun15-Jan-10 3:23 
GeneralRe: C++ - Virtual Destructor Pin
Stuart Dootson15-Jan-10 3:38
professionalStuart Dootson15-Jan-10 3:38 
GeneralRe: C++ - Virtual Destructor Pin
davarun15-Jan-10 4:34
davarun15-Jan-10 4:34 
GeneralRe: C++ - Virtual Destructor Pin
Stuart Dootson15-Jan-10 4:44
professionalStuart Dootson15-Jan-10 4:44 
QuestionVC++ 2008 MFC Pin
2buck5613-Jan-10 14:03
2buck5613-Jan-10 14:03 
AnswerRe: VC++ 2008 MFC Pin
Chris Losinger13-Jan-10 16:25
professionalChris Losinger13-Jan-10 16:25 
GeneralRe: VC++ 2008 MFC Pin
2buck5613-Jan-10 17:51
2buck5613-Jan-10 17:51 
GeneralRe: VC++ 2008 MFC Pin
Chris Losinger13-Jan-10 18:18
professionalChris Losinger13-Jan-10 18:18 
AnswerRe: VC++ 2008 MFC Pin
Rajesh R Subramanian13-Jan-10 17:56
professionalRajesh R Subramanian13-Jan-10 17:56 
AnswerRe: VC++ 2008 MFC PinPopular
Joe Woodbury13-Jan-10 20:15
professionalJoe Woodbury13-Jan-10 20:15 
GeneralRe: VC++ 2008 MFC Pin
2buck5614-Jan-10 3:03
2buck5614-Jan-10 3:03 
QuestionHow can I get Operating System Info? Pin
Software200713-Jan-10 8:36
Software200713-Jan-10 8:36 

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.