www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/17/16:10:12

Message-Id: <m0yxGly-000S4XC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: jimeza AT usa DOT net, djgpp AT delorie DOT com
Date: Fri, 17 Jul 1998 17:15:02 +0000
MIME-Version: 1.0
Subject: Re: the call of the constructor!
In-reply-to: <01bdb1b1$0651e500$071f1bc4@default>

"Jorge Ivan Meza Martinez" <jimeza AT usa DOT net> wrote:

[snipped code]
> *always* in the Clase1 constructor is called the empty constructor for k, is
> it true?

I don't have the C++ standard here, but it looks like the natural 
thing.

> when I try to write "Clase1 ()" the constructor "Clase2()" for k is
> automatically called,

Logic because k is Clase2 and part of Clase1.

>  but what about if I want to call "Clase2 ( String,
> int, ...... );" instead of "Clase2()"; 

Yes, what about it? what does it change? I think it doesn't have to 
change anything. Again I don't have the standard but it looks the 
natural thing because k is just a member of Clase1, nothing more.

> in BC you can make "k = "Clase2
>  String, int, ...... )" but now I can't with DJGPP.

Never trust in BC++ it have a lot of non-portable extentions and 
normally Borland doesn't put it clear.
 
> remember that in this case I am using objects created with out new.

Yes and that's the point, I think you need:

class Clase1 
{ 
.....
 Clase2 *k;
}

And inside the Clase1 constructor:

k=new Clase2(....anything you want...);

Instead of expecting some automatic behavior.

SET
------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


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