Why should i employ new instead of truthful old malloc()?, C/C++ Programming

Why should I employ new instead of truthful old malloc()?

A: Constructors/destructors, type safety, overridability.

Constructors/destructors: unlike malloc(sizeof(Fred)), new Fred() calls Fred's constructor. Likewise, delete p calls *p's destructor.Type safety: malloc() returns a void* that isn't type safe. new Fred() returns pointer of right type (a Fred*).

Overridability: new is an operator which can be overridden by a class, whereas malloc() is not overridable on a per-class basis.

 

Posted Date: 3/19/2013 8:28:43 AM | Location : United States







Related Discussions:- Why should i employ new instead of truthful old malloc()?, Assignment Help, Ask Question on Why should i employ new instead of truthful old malloc()?, Get Answer, Expert's Help, Why should i employ new instead of truthful old malloc()? Discussions

Write discussion on Why should i employ new instead of truthful old malloc()?
Your posts are moderated
Related Questions
write a prgm to find minimum total number of shelves including the intial one required for loading process

This is what I need help with. "Create a program creates an interface allowing the user to select from some other programs I have made one being a money converter and the other ca

Write a C++ program that reads from keyboard 3 integers, with proper input prompt, and then displays the maximum sum of any pair of numbers from these three. If the 3 numbers are 5

Define the Data Type Modifiers in C language? There are three data types(int, float & double) above have the following modifiers. 1. short 2. long 3. signed 4. unsigned

(a) Write a recursive procedure (digits n) that computes the number of digits in the integer n using a linear recursive process. For example, (digits 42) should return 2 and (digit


Most first graders know that nine hundred and ninety nine plus one is one thousand, but C++ doesn't! Sure, a computer can easily compute 999 + 1 and get 1000. But reading and writi

i am using otlv4 for database connecttvity, while i try to get all tables list from current database using query "$SQLTables" no output is displayed though programe compiles coretl

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Write a Program to illustrate Array with Strings? main() { static char name[]="devdas"; int i; i=0; while(name[i]!='\0') { printf("%c",name[i]); i=i+1; } } In the