Thanks for the answer -:) On Thu, Jul 21, 2011 at 6:09 PM, Kashyap Krishnakumar <kashyap...@gmail.com>wrote:
> You can also do > > void f(a ** b) > { > (*b) = new a(); > (*b)->set(5); > } > int main() > { > a *a1; > f(&a1); > cout<<"x = "<<a1->get(); > return 0; > } > > The logic behind this is the basic difference between call by value and > call by reference :-) In your original code, the changes in b will not > reflect in a. In C you achieve it by using double pointers, and in C++ you > can achieve it by using the & operator! :-) > > -- > Kashyap.K, > III year, B.E. CSE, > College of Engineering Guindy, > Anna University, > Chennai. > -- > If you've never failed, you've never lived! > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards n Luv Saurabh Badhai -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.