vehiptr is no longer pointing to the first element of the array. The pointer value that you pass to delete has to be the same pointer value that was returned from new.
this code is working but can i do better then that
int main()
{
int vnum = 0;
VEHICLE* vehiptr;
VEHICLE *dptr;
VEHICLE * zptr;
cout<<"Please enter the number of vehicle: ";
cin>>vnum;
vehiptr = new VEHICLE[vnum];
dptr = vehiptr;
zptr = dptr;
for(int a=1;a<=vnum;a++)
{
dptr->get_input();
if(a<vnum)
{
dptr++;
}
}
for(int i =1;i<=vnum;i++)
{
zptr->display();
if(i<vnum)
{
zptr++;
}
int main()
{
int vnum = 0;
VEHICLE* vehiptr;
cout<<"Please enter the number of vehicle: ";
cin>>vnum;
vehiptr = new VEHICLE[vnum];
for(int a=1;a<=vnum;a++)
{
vehiptr[a].get_input();
}
for(int i =1;i<=vnum;i++)
{
vehiptr[i].display();
}
delete [] vehiptr;
system("pause");
}