Re: static + pointer and reaching the private field of another class
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 02/16/05
- Next message: Phlip: "Re: TCP/IP"
- Previous message: Jose Garcia: "C/C++ sources compiled with MINGW(DevCPP) as C++"
- In reply to: mehmet canayaz: "static + pointer and reaching the private field of another class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 16 Feb 2005 00:04:31 -0500
"mehmet canayaz" <memocan@gmail.com> wrote...
> I have a class called [...]
We much better understand C++ here. Why don't you simply post your
code instead of explainging what it is?
> But I saw an implementation of the same static function that was able
> to see the private field "name" using pointers such as :
>
> foo x = new foo ( my_array[i]->name)
>
> so as he incremented my_array he was creating new foo objects and
> copying them in another array, and this was working..
>
> I do not understand how this works because bar.cpp and foo.cpp has
> nothing in common except bar.cpp includes foo.h . is this is enough for
> bar to be able to see the private field of foo objects? -I dont think
> so -
> Does it have anything to do with static ? or pointers?
Probably. I don't see any static or pointers in your post, though.
Try again, and this time post C++.
> ps: when we changed the second implementation as
> foo x = new foo (*my_ar[i].name )
> it didn't work.
Probably because . has higher precedence than *. Try
foo x = new foo( (*my_ar[i]).name );
V
- Next message: Phlip: "Re: TCP/IP"
- Previous message: Jose Garcia: "C/C++ sources compiled with MINGW(DevCPP) as C++"
- In reply to: mehmet canayaz: "static + pointer and reaching the private field of another class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]