The answer for first question would be a segmentation fault...since none of a or b has been allocated any memory. Had it been A *a=new A; then the call to a->print() would not result into a segmentation fault.
I think the purpose of this question was to know about this pointer concept about dynamic allocation and the statement A *b=NULL; was only given to puzzle someone. On Aug 19, 4:56 pm, luckyzoner <luckyzo...@gmail.com> wrote: > 1. Suppose a class A is given as : > > class A > { > public : > void print() > { > cout<<"Hello"; > } > } > > int main() > { > A * a; > A* b = NULL; > > a->print(); > b->print(); > > } > > What is the output? > > 2. Given an array containing 0,1,2 in any order. Sort the array in a > single pass. > 3. Write a code to implement spiral traversal of the BST. > 4. Given a string containing the binary representation of a number. > Write a code to find the 2s complement of the number. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.