Program given by sir i.e given in Reema Thareja on Overloading of new and delete operators is not working . Debug it !!
Page 1 of 1
Program given by sir i.e given in Reema Thareja on Overloading of new and delete operators is not working . Debug it !!
- Code:
#include<iostream>
using namespace std;
class Array
{
private:
int *arr;
public:
void * operator new(size_t size)
{
void *parr=::new int[size];
return parr;
}
void operator delete(void *parr)
{
::delete parr;
}
void get_data();
void show_data();
};
void Array::get_data()
{
cout<<"\nEnter the elements: ";
for(int i=0;i<5;i++)
cin>>arr[i];
}
void Array::show_data()
{
cout<<"\nThe Array is : ";
for(int i=0;i<5;i++)
cout<<" "<<arr[i];
}
int main()
{
Array *A = new Array;
A->get_data();
A->show_data();
delete A;
return 0;
}
iamdsc_0410- Posts : 14
Join date : 2017-04-11
Age : 26
Location : IIIT Kalyani
Similar topics
» Overloading new and delete operator program
» please check the error and correct the program
» templet program
» IP6: Write a C++ program that uses the concept of hybrid inheritance.
» Program related to Object Slicing : Why the output is not coming In Base a=2 ?
» please check the error and correct the program
» templet program
» IP6: Write a C++ program that uses the concept of hybrid inheritance.
» Program related to Object Slicing : Why the output is not coming In Base a=2 ?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|