www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/03/05:35:51

Date: Mon, 3 Feb 1997 11:24:42 +0100 (MET)
From: Miguel Murillo <mmurillo AT ideafix DOT cps DOT unizar DOT es>
To: Jean-Gaël GRICOURT <jean-gael DOT gricourt AT snet DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: Pb with private members ...
In-Reply-To: <32F39147.6896@snet.net>
Message-ID: <Pine.LNX.3.95.970203112334.28163A-100000@ideafix.cps.unizar.es>
MIME-Version: 1.0


On Sat, 1 Feb 1997, Jean-Ga=EBl GRICOURT wrote:

> Please tell me what do you think about this code ?
>=20
> ------------------------------
>=20
> #include <iostream.h>
>=20
> class Object
> {
>  private:
>         int data;
>  public:   =20
>         Object(int=3D0);
>         Object(Object&);
>         ShowData();
> };
>=20
> Object::Object(int d)
> { data=3Dd; }
>=20
> Object::Object(Object &o)
> { data=3Do.data; }
>=20
> Object::ShowData()
> { return data; }
>=20
>=20
> main()
> {
>  Object InstObject1(5),InstObject2;
>=20
>  InstObject2=3DInstObject1;
>  cout<<InstObject2.ShowData();
>  return 0;
> }
>=20
> -----------------------------------
>=20
> In the constructor "Object(Object &o)", the member "o.data" is accessed
> although it is a private member !
> Is there something wrong ?
>=20
> I used DJGPP 2.01 and I had no pb to compile this and it worked fine.
>=20

The program is fine !!=20
I don't problem=20
=09=09=09=09=09=09Miguel

- Raw text -


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