Dear Brothers,
i am facing a problem
class compactdisc
{
char title[20];/string a;
int capacity;
public:
compactdisc();
compactdisc(cha r [],int);
};
class cd_drive
{
int speed;
char manufact[20];
compactdisc *ptr;
public:
cd_drive();
cd_drive(char [], int ,compactdisc *);
~cd_drive();
};
cd_drive::cd_dr ive(char a[], int spd ,compactdisc * a);
{
int counter=0;
counter=strlen( a);
for(int i=0;i<counter;i ++)
manufact[i]=a[i];
for(int j=counter;j<20; j++)
manufact[j]=0;
ptr=new compactdisc;
ptr=a;
}
*************** *************** *************** ******
cd_drive::~cd_d rive()
{
// how can i write the destructor of this if i write this
statement it gives memory leakage
// what is the reason about this ..is the way of deletion is
incorrect or any thing else
delete ptr;
}
int main()
{
compactdisc c1("programming ",700);
compactdisc *c2;
c2=new compactdisc;
cd_drive("micro soft",210,c2);
delete c2;
return 0;
}
Please explain ! and also if any suggestion to make the program
efficient ..
thanks
your Brother.