Erik Wikström
12/18/2008 6:32:00 PM
On 2008-12-18 13:44, zs0723 wrote:
> On Dec 18, 7:01 pm, Rolf Magnus <ramag...@t-online.de> wrote:
>> zs0723 wrote:
>> > On Dec 18, 5:20 pm, zs0723 <zs0...@gmail.com> wrote:
>> > what about if use pointer as a member
>>
>> > class B
>> > {
>> > A * p;
>> > }
>>
>> > do i need to recompile ?
>>
>> That is one way to get around this. Here is a link that describes how to
>> stay binary compatible. It's written specifically for KDE applications, but
>> most of it applies to non-KDE programs written in C++, too.
>
> But i think we still have problem if we use pointer. In the
> implementation of B , we need to create a A object before use
> the pointer , and if Class B didn't recompile , it'll use old
> constrcutor of A to create A object.I think this is problem.
An alternative would be to pass an A pointer to B's constructor, and
construct the A instance outside of B:
struct B
{
A* a;
B(A* a_) : a(a_) {}
};
Of course this only means that you no longer have to recompile B, but
you still need to recompile the part that that uses B.
--
Erik Wikström