Mail Archives: djgpp/1997/02/03/05:35:51
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 -