Write a program that creates a vector of user given size M using NEW operator( by creating a class)
Answers
Answered by
2
Answer:
#define null 0
#include <iostream.h>
#include <conio.h>
void main()
{
void memory(int);
clrscr();
textcolor(16);
textbackground(1235);
clrscr();
cout<<"Enter Memory M you Want to create:-";
int size;
cin>>size;
memory(size);
getch();
}
//MEMORY function
void memory(int s)
{
int *m = new int[s];
if(m!=null)
{
cout<<"\nWe are Successfull";
cout<<"\n\n\n\n\tNow You Want to Delete This Created Memory";
cout<<"\n\n\tEnter Y or y for Deleting else anything:-";
char ch;
cin>>ch;
if(ch=='y' || ch=='Y')
{
delete[]m;
cout<<"\n\n\n\tCreated Memory is Delete";
}
else
cout<<"\n\n\tOK, your Memory is Safe";
}
else
cout<<"\nWe are UN-Successfull";
}
Similar questions
Math,
9 days ago
Computer Science,
9 days ago
Math,
9 days ago
Science,
19 days ago
Math,
8 months ago