R
RS
Hi,
What is the difference between new() and malloc()?
RS
What is the difference between new() and malloc()?
RS
RS said:What is the difference between new() and malloc()?
Victor said:'new' is the C++ way to create object in free store.
'mallow' is the C way to allocate some memory.
That's explained by lots of books. You can even google it.
Simply put, new is OOP, while malloc is not.
E. Robert Tisdale said:You need to add malloc to your spell checker dictionary.
Dave said:[...] I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
Dave said:[...] I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
Really? Why? What's so bad about 'malloc'? It is
often _the_ function to call if you overload the
operator new...
Hi,MatrixV said:That's explained by lots of books. You can even google it.
Simply put, new is OOP, while malloc is not.
monasteryDave Vandervies said:That's odd; I use malloc for OOP quite regularly.
Mind you, I do OOP in C quite regularly (for assorted reasons, most
of them actually reasonable), and I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
dave
--
Dave Vandervies (e-mail address removed)
My personal best estimate is that 90% of existing C code is crap (F various VO
crap), and 90% of existing NotC code is crap too. (I expect this to be true of
non-existing code as well.) --Dimitri Mazuik in the scary devil
MatrixV said:You though you are doing quite well, but you are not. As Mr. Kirunge said,
malloc can't do many things, it just alloc a memory space. Of course you can
implement new by malloc, and in fact that's the way it goes.
I suggest you to google it instead of asking here. I read a lot on this and
it's hard to put them all here.
"Dave Vandervies" <[email protected]> ????
news:[email protected]...
Victor said:'new' is the C++ way to create object in free store.
'mallow' is the C way to allocate some memory.
Victor said:Dave said:[...] I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
Really? Why? What's so bad about 'malloc'? It is
often _the_ function to call if you overload the
operator new...
Basavaraj said:-- calling constructor after allocating memory(new calls
constructor as well)
-- Type safety: (new returns a pointer of the right type)
WRONG! The operator can NOT be overriden. Only the memory allocator-- Overridability: (new is an operator that can be overridden)
Ron Natalie said:Victor said:Dave said:[...] I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
Really? Why? What's so bad about 'malloc'? It is
often _the_ function to call if you overload the
operator new...
Malloc doesn't create objects. It allocated bytes.
new creates objects.
RS said:Hi,
What is the difference between new() and malloc()?
RS
No, and you know it. The new operator creates objects.Victor said:Ron Natalie said:Victor said:Dave Vandervies wrote:
[...] I never use malloc when I'm actually
writing C++ code, whether I'm doing OOP or not...
Really? Why? What's so bad about 'malloc'? It is
often _the_ function to call if you overload the
operator new...
Malloc doesn't create objects. It allocated bytes.
new creates objects.
No!... Really? I learn something new every day. So,
when I overload operator new, I need to call another
operator new, is that what you're saying?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.