delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/11/23:07:29

From: "Johan Venter (aka sphinX)" <^_^@delorie.com>
Newsgroups: comp.os.msdos.djgpp
Subject: classes: variable scope
Date: Sat, 12 Dec 1998 14:00:38 +1100
Lines: 52
MIME-Version: 1.0
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: 203.40.82.28
Message-ID: <3671e980.0@139.134.5.33>
X-Trace: 12 Dec 1998 13:56:48 +1000, 203.40.82.28
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I've got a bit of a nagging problem.
I'm building a cdrom class to interface with MSCDEX and I've reached a wall.
I'll use an example here to illustrate my problem instead posting al my code.

For example, my class is defined as this:

class CDROM {
   private:
      unsigned char installed;

   public:
      CDROM(void);
      unsigned char is_mscdex_installed(void);
}

In my constructer function, I do the installation check and put 1 in installed if mscdex
is i installed, else it contains zero. I know this constructer works, because I put a
printf() after the install check to see if it was working and it returned that MSCDEX was
installed.
My function CDROM::is_mscdex_installed(void) is as follows:

unsigned char CDROM::is_mscdex_installed(void)
{ return(installed); }

this is my main:

int main(void)
{
   CDROM cdrom;

   if (cdrom.is_mscdex_installed())
      printf("MSCDEX Is Installed.");
   else
      printf("MSCDEX Is Not Installed.");

   return 0;
}

This refuses to work although I know the installation check works and I've traced the
problem to the scope of my installed variable.
Surely the CDROM::is_mscdex_installed() should return the right value?

This is also the case with my other variable (version, number of cd drives, first drive,
device name etc)

It's driving my crazy!!!!
--
sphinX

e-mail:   sphinx AT iname DOT com
icq:   3643877

- Raw text -


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