delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/30/23:35:52

From: "DarkSun" <basicvengance AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: try, throw, and catch
Date: Tue, 30 Mar 1999 19:58:12 -0800
Organization: Uniserve
Lines: 47
Message-ID: <922852481.604485@neptune.uniserve.ca>
References: <370121EB DOT 33506B4E AT jps DOT net>
NNTP-Posting-Host: 204.244.163.50
NNTP-Posting-Date: Wed, 31 Mar 1999 03:54:44 GMT
X-Trace: 922852484.471.94 L6ZHA2YYUA332CCF4C usenet1.supernews.com
X-Complaints-To: newsabuse AT remarQ DOT com
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Cache-Post-Path: neptune.uniserve.ca!204.244.194.47
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>#include <iostream.h>
>#include <string.h>
>
>struct sorry{
>    const char *error_msg;
>    sorry( const char *p) : error_msg(p) {}     <------ Function in a
struct!  I DONT THINK SO!
>};
>
>int main()
>{
>    try {
>        throw sorry( "test 3");
>    }
>    catch ( sorry stuff ) {
>        cerr << "Sorry, ";
>        cerr << stuff.error_msg ;
>        cerr << '\n';
>    }
>    cout << '\n';
>}


I see your problem... try changeing the prog to this :
#include <iostream.h>
#include <string.h>

class sorry{
    public:
    const char *error_msg;
    sorry( const char *p) : error_msg(p) {}
};

int main()
{
    try {
        throw sorry( "test 3");
    }
    catch ( sorry stuff ) {
        cerr << "Sorry, ";
        cerr << stuff.error_msg ;
        cerr << '\n';
    }
    cout << '\n';
}


- Raw text -


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