www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/26/23:14:15

Message-ID: <37252B2E.2C928964@unb.ca>
Date: Tue, 27 Apr 1999 00:12:47 -0300
From: Endlisnis <s257m AT unb DOT ca>
X-Mailer: Mozilla 4.04 [en] (Win95; U)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: Help
References: <JJDHMNOMDDBJAAAA AT zdnetmail DOT com>
X-Info: BrunNet, Inc. 888-278-6638
Reply-To: djgpp AT delorie DOT com

Paul A Jimenez wrote:

>  I don't know if this is a complier bug or just a mistake that I am not catching.
>   ------------------------------------------------------------------------------
> #include <iostream.h>
> #include <conio.h>
>
> class stack
> {
>  public:
>  static int stack_count ;
>  public:
>
>         static int get_count(void)
>         {
>             return(stack_count);
>         }
>         stack()
>         {
>           ++stack_count;
>         }
> };

int stack::stack_count;
//It needs to set aside space for the variable.

> main()
> {
>  stack a_stack;
>  stack b_stack;
>  stack c_stack;
>
>  clrscr();
>
>  cout << stack::get_count;
> }

    That compiles and runs, but it output's "1" when I run it.  I would have expected it to output "3".  Can anyone explain it?

--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT BrunNet DOT Net
          Endlisnis AT HotMail DOT com
          ICQ: 32959047

          (Once upon a time there was light in my life)
          (But now there's only _______________ ???)


- Raw text -


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