delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/17/15:18:35

Message-ID: <38ABA7FE.10B29BCB@earthlink.net>
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Organization: Nocturnal Aviation
X-Mailer: Mozilla 4.7 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: c++
References: <HEHq4.4290$CC3 DOT 119351 AT wagner DOT videotron DOT net>
Lines: 98
Date: Thu, 17 Feb 2000 07:49:08 GMT
NNTP-Posting-Host: 209.246.88.61
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: newsread1.prod.itd.earthlink.net 950773748 209.246.88.61 (Wed, 16 Feb 2000 23:49:08 PST)
NNTP-Posting-Date: Wed, 16 Feb 2000 23:49:08 PST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


Jean-Francois Desjardins wrote:
> 
> 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):xPos(X), yPos(Y),
        Length(Len), Width(Wid)
    {
    }
    ~Panel()
    {
    }
};


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

int main(void)
{
    Panel Menu(0, 0, 100, 100);
    Desktop foo;
    return 0;
}








> 
> 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

-- 
Martin Ambuhl	mambuhl AT earthlink DOT net

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

- Raw text -


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