delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/29/23:46:29

Message-ID: <356F7485.2F71@banet.net>
Date: Fri, 29 May 1998 22:52:53 -0400
From: gavlene AT banet DOT net
Reply-To: gavlene AT banet DOT net
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: try, throw, catch & const
NNTP-Posting-Host: 129.37.113.57
Organization: IBM.NET
Lines: 28
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

hi,

can someone tell me why the following catch failed if a const is used?
it works if no const used in front of char *.
this piece of code works in Sun C++ compiler.

thanks,

leetravis AT hotmail DOT com


int main(int argc, char *argv[]) 
{
   try {
	throw "unable to catch";
   } 
   catch (const char* sError) { // fails to catch
//   catch (char* sError) {
	cerr << sError << endl;
	exit(1);
   } 
   catch (...) {
	cerr << "unknow exception throw" << endl;
	exit(1);
   } 

   return(0);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019