delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/17/22:11:46

Message-ID: <A34D5D3BF0DFD2119E3D0008C70840FA04FD8B@TWZNT11>
From: Nigel Atkinson <Nigel DOT Atkinson AT MeridianEnergy DOT co DOT nz>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: c++
Date: Fri, 18 Feb 2000 08:33:34 +1300
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2650.21)
Reply-To: djgpp AT delorie DOT com

Here is a solution, I think there is a better way, but this will work.

Define another contstuctor for Panel that dose nothing.

Panel()	{ return }

You now can in Desktop write...

class Desktop{
 public:
  Panel Menu;
  Panel Icon;
}

without any errors.

Now add a contstuctor to desktop like....

Desktop()
{
	Menu.Panel( 0, 0, 100, 100 );
	Icon.Panel( 0, 100, 100, 100 );
	return;
}

Like I said there is a better way - (which has escaped me at present) - but
this should get you going.

Nigel Atkinson


-----Original Message-----
From: Jean-Francois Desjardins [mailto:jfd50 AT videotron DOT ca]
Sent: Thursday, 17 February 2000 13:54
To: djgpp AT delorie DOT com
Subject: c++ 


Hello!
I want to know how I can initialize an object, within an object:
ex:

class Panel{
private:
 char xPos;
 char yPos;
 char Length;
 char Width;
public:
 Panel( char X, char Y, char Len, char Wid);
 ~Panel();
};

Panel( char X, char Y, char Len, char Wid);{
 xPos=X;
 yPos=Y;
 Length=Len;
 Width = Wid;
}

class Desktop{
 public:
  Panel Menu(0,0,100,100);
  Panel Icon(0,100,100,100);
}

 that way, it give me an ANSI c++ error.

I know if I do
int main(void){
 Panel Menu(0,0,100,100);
 return(0);
}

without the Desktop class it will work, but I can't do that... I need the
desktop class.

Can anyone help please? thanks


- Raw text -


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