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
A: C++, unlike only about every other language with exceptions, is extremely accomodating while it comes to what you can throw. Actually, you can throw anything you akin to. That b

how to explain working of bus connection

Project Description: I have a barber salon I am seeking someone to build me software for my PARTNER PT6910 touch screen till system. This software must add multiple staff login

write a C program for padovan string for a natural number   program 1 : package test.padovanstring; public class PadovanString {     public int stringOccurrences(int n,

please help me get all the inbuilt functions in c++

A skilled programmer is required to build a standalone module to extract, parse and store in database tables, word count data from web pages and RSS feeds. The module can take R

Access privileges 1. If the designer of the base class needs no one, not even a derived class to access a member, then that member should be made private. 2. If the designer

write a c program that multiplies 3 martices

how can i easily make a program?

What are  Id e n t i f ie rs a n d C o n s t a n ts in C++? Id e n t i f ie r a n d C o n s t a n t : I d e n t i f ie r