Click here to Skip to main content
15,907,396 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:09
Maxwell Chen3-Feb-08 22:09 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:19
George_George3-Feb-08 22:19 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:30
Maxwell Chen3-Feb-08 22:30 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:42
George_George3-Feb-08 22:42 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 22:52
Maxwell Chen3-Feb-08 22:52 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 22:56
George_George3-Feb-08 22:56 
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 23:02
Maxwell Chen3-Feb-08 23:02 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 23:24
George_George3-Feb-08 23:24 
Seems we are both wrong, Maxwell!


I have written some code which verified that the caught object instance is not the original one we thrown. Looks like we only get a temporary exception object in catch block?

Here is my code. You can see two object instance is created.

class Foo {
public:
	Foo(int input)
	{
		this->a = input;
		cout << this << endl;
	}

	Foo (const Foo& input)
	{
		this->a = input.a;
		cout << this << endl;
	}
	int a;
};

void foo()
{
	try {
		Foo *f = new Foo (100);
		throw *f;
	} catch (const Foo& e)
	{
		cout << e.a << endl;
	}
}

int main()
{
	foo();
}


Any comments?


regards,
George
GeneralRe: life cycle of exception object Pin
Maxwell Chen3-Feb-08 23:35
Maxwell Chen3-Feb-08 23:35 
GeneralRe: life cycle of exception object Pin
George_George3-Feb-08 23:50
George_George3-Feb-08 23:50 
Generalcstring to tchar* conversion Pin
guru moorthy.k3-Feb-08 21:05
guru moorthy.k3-Feb-08 21:05 
GeneralRe: cstring to tchar* conversion Pin
Cedric Moonen3-Feb-08 21:11
Cedric Moonen3-Feb-08 21:11 
GeneralRe: cstring to tchar* conversion [modified] Pin
CPallini3-Feb-08 21:46
mveCPallini3-Feb-08 21:46 
GeneralRe: cstring to tchar* conversion Pin
toxcct4-Feb-08 1:48
toxcct4-Feb-08 1:48 
GeneralRe: cstring to tchar* conversion Pin
CPallini4-Feb-08 2:06
mveCPallini4-Feb-08 2:06 
GeneralRe: cstring to tchar* conversion Pin
toxcct4-Feb-08 2:11
toxcct4-Feb-08 2:11 
GeneralRe: cstring to tchar* conversion Pin
CPallini4-Feb-08 2:16
mveCPallini4-Feb-08 2:16 
Generalsmall issue with combo box. Pin
Chandrasekharan P3-Feb-08 20:58
Chandrasekharan P3-Feb-08 20:58 
GeneralRe: small issue with combo box. Pin
CPallini3-Feb-08 22:02
mveCPallini3-Feb-08 22:02 
GeneralRe: small issue with combo box. Pin
Chandrasekharan P4-Feb-08 0:15
Chandrasekharan P4-Feb-08 0:15 
Questionhow to devide the client rect of frame window? Pin
Miss_F3-Feb-08 20:38
Miss_F3-Feb-08 20:38 
AnswerRe: how to devide the client rect of frame window? Pin
Cedric Moonen3-Feb-08 21:01
Cedric Moonen3-Feb-08 21:01 
GeneralRe: how to devide the client rect of frame window? Pin
Miss_F3-Feb-08 22:30
Miss_F3-Feb-08 22:30 
AnswerRe: how to devide the client rect of frame window? Pin
CString(0xcccccccc)4-Feb-08 4:11
CString(0xcccccccc)4-Feb-08 4:11 
QuestionToolbar height Pin
nitin33-Feb-08 19:29
nitin33-Feb-08 19:29 

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.