Re: [Dev-C++] Buggy standard library?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2004-04-12 23:49:52
|
No, the program doesn't end when main() returns. The desctructors for
global objects will still be called. The problem with this program is that
they are called _after_ system("PAUSE").
/Per W
On Mon, 12 Apr 2004, Scott Simontis wrote:
> Try manually calling the destructor in your code. I am not a master of
> C++, but I think I see what is going on here. The "World" class is
> global. Therefore, its life is the entire program. However, when main
> ends, the program ends. The solution here would probably to create an
> instance of the class within main or call the destructor yourself in the
> code, but I think the latter is poor programming, does anybody else know?
> Latif Dokter wrote:
>
> > here is the full code
> > #include <iostream>
> > #include <stdlib.h>
> >
> > using namespace std;
> > class World
> > {
> > public:
> > World () { std::cout << "Hello!\n"; }
> > ~World () { std::cout << "Goodbye!\n"; }
> > };
> >
> > World TheWorld;
> >
> > int main(int argc, char *argv[])
> > {
> >
> > system("PAUSE");
> > return 0;
> > }
> >
> > /-------Original Message-------/
> >
> > /*From:*/ Scott Simontis <mailto:age...@co...>
> > /*Date:*/ 04/12/04 10:55:55
> > /*To:*/ Latif Dokter <mailto:ld...@op...>
> > /*Subject:*/ Re: [Dev-C++] Buggy standard library?
> >
> > Did you call the destructor?
> > Latif Dokter wrote:
> >
> > > I am using Dev.C++ 4.9.8.7 When creating a program with class World
> > > where World () {} says Hello and ~World() {} says goodbye World
> > > TheWorld; when compiled and executed
> > > in Ms dos console the program prints hello but doesn't print goodbye I
> > > have read that I may have a buggy version of the standard library if
> > > so is there a patch if not what is happening and how can I fix it
> > >
> > >
> > >
> > >
> > > ____________________________________________________
> > > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9
> > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>> /IncrediMail/
> > > - *Email has finally evolved* - *_Click Here_*
> > > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9
> > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>>
> >
> >
> >
> >
> >
> >
> > ____________________________________________________
> > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9> /IncrediMail/
> > - *Email has finally evolved* - *_Click Here_*
> > <http://www.incredimail.com/redir.asp?ad_id=309&lang=9>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|