the difference between new and malloc

Answer Posted / cl

The difference is the invocation of constructor: malloc
does not do it.

Is This Answer Correct ?    11 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use encapsulation in oops?

522


Why is polymorphism used?

586


What are main features of oop?

633


Whats oop mean?

595


What is inheritance and how many types of inheritance?

622






can we make game by using c

3424


What is this pointer in oop?

557


What is polymorphism what is it for and how is it used?

575


Get me a number puzzle game-program

1694


Why is there no multiple inheritance?

570


Why is oop useful?

602


#include #include #include #include void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

3251


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

1698


Can abstract class have normal methods?

614


What is debug class?what is trace class? What differences are between them? With examples.

1610