What is the difference between creating an object,
using 'new' and using 'malloc'?

Answer Posted / btech

new operator returns a pointer of the correct type and
malloc() returns a void*

New calls the object’s constructor and malloc does not.

Any object created with new must be freed using delete and
where as malloc() and free() allocates and deallocates
memory

new operator can be overloaded by a class, where as
malloc() can't be overloaded.

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does I oop mean?

616


Is c++ an oop?

588


How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

1652


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

693


What data encapsulation is in c++?

595






Why multiple inheritance is not possible?

598


If I is an integer variable, which is faster ++i or i++?

588


Is c or c++ more useful?

574


What is #include c++?

567


Write about c++ storage classes?

746


Discuss the role of C++ shorthands.

543


In C++ what is the meaning of data hiding?

612


What are c++ manipulators?

607


What is class and structure in c++?

556


What Is A Conversion Constructor C++ ?

610