answersLogoWhite

0


Best Answer

#include<iostream>

struct object

{

int m_data;

};

void main()

{

object obj=new object;

obj.m_data = 42;

delete( obj );

return( 0 );

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program for new and delete operator using c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write c plus plus program for new and delete operator using class?

#include&lt;iostream&gt; class foo{ int m_data; }; int main() { foo* p=new foo; delete( foo), foo=NULL; return(0); }


Which operator is used for deallocating memory in c plus plus?

delete


Why use new and delete operator overloading in c plus plus?

one reason to use new and delete operator overloading in c++ is when you are using your own memory manager code. when the user of your code calls the new keywork, your memory manager code can allocate memory.


Do you have to use delete operator on C plus plus strings before exiting your application?

no you dont


What is the memory management operator in c plus plus?

There is no memory management operator in C++ -- it is an unmanaged language. You use the C++ new operator to allocate memory, and use the C++ delete operator to release previously allocated memory.


Program to delete elements at both ends in a dequeue using c plus plus?

#include&lt;deque&gt; std::deque&lt;int&gt; deq; deq.push_back (42); deq.pop_back (); deq.push_front (0); deq.pop_front ();


Can you mix new and malloc in the same C plus plus program?

Yes. Note: This is generally a bad idea. Using delete on something you malloc'ed or free on something you new'ed usually will cause Bad Things to happen.


The four most common mistakes in C plus plus?

Using the assignment operator (=) instead of the equality operator (==).Failing to terminate a class declaration with a semi-colon (;).Using C-style code (e.g., malloc/free) instead of sticking to C++ principals (e.g., new/delete). If you want to write C-style code, use C, not C++.Ignoring object lifetime (dangling pointers or references).


How a program in c that will add 2 numbers without using any plus operator?

int main() { int a=10,b=20; while(a--) b++; printf("%d",b); } or: a -= -b;


What is the operator is used to allocate the memory in c plus plus?

calloc operator,malloc operator


How can you remove music and picture files from your zen v plus?

go on to the CD that comes with it and then you can delete it with the program by right clicking on the files while you zen is plugged in. go on to the CD that comes with it and then you can delete it with the program by right clicking on the files while you zen is plugged in.


What is the operator that cannot be overloaded in c plus plus and java?

conditional operator , size of operator , membership operator and scope resulation operator can not be overload in c++