Hi Michael,
Thanks for the response. Your solution will indeed work, but the side
effect is that spB and spC only have access to methods available in
the base class. Imagine that B & C have unique methods that I want to
access in main like.
main()
{
A base;
shPtrB spB(new B());
shPtrC spC(new C());
spB.PrintBrad(); // unique to B
spC.PrintMichael(); // unique to C
// this will fail obviously, but how else can I get access to unique
methods in B & C
base.AddChild(spB);
base.AddChild(spC);
}
Thanks for your help
Brad
On 9/7/07, Michael Fawcett
On 9/7/07, Brad Ryder
wrote: main() { A base; shPtrB spB(new B()); shPtrC spC(new C());
// I dont want to typecast spB or spC
A.AddChild( (shPtrA) spB); A.AddChild( (shPtrA) spC); }
Simply stop using shPtrB and shPtrC, and just use shPtrA. e.g.,
main() { A base; shPtrA spB(new B()); shPtrA spC(new C());
// works fine A.AddChild(spB); A.AddChild(spC); }
HTH,
--Michael Fawcett _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users