Re: [Dev-C++] Buggy standard library?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Scott S. <age...@co...> - 2004-04-12 23:32:09
|
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>
|