Ehm, my logic may be incorrect (pointers are my weakness) but item *d = p creates a pointer that points to p, which is a pointer that points to an array of class "items".
No you cannot use p->putdata(); because it will display the memory address of the new item[2] instead of the value. I believe that's correct.
item *p=new item[2];
p is a pointer that points to dynamically allocated memory.
item *d=p;
d is a pointer that is reassigned to p. IE: it points to the same thing p points to. Therefore d also points to the dynamically allocated memory.
p->putdata(); and d->putdata(); are both exactly the same, as both pointers point to the same thing and are thus identical.
item *p=new item[2];//NOW P POINTS TO THE FIRST array element
item *d=p; //u create a pointer d that also points to the same element.NOTE:d, p are two distinct entities
int i,j,k;
for(i=0;i<2;i++){
cout <<"Enter item,price"<<endl;
cin>>j>>k;
p->getdata(j,k);
p++;
}//now P points to the last array element;d still points to the 1st
for(i=0;i<2;i++){
d->putdata();//********here d points within array bounds but p goes beyond bounds of the array, so is meaningless **********
d++;
}
return 0;
}