Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with coding please!

Status
Not open for further replies.

gazflat33

Technical User
Nov 22, 2002
13
GB
Hi people.
I am doing some very basic objects work, trying to help a real life problem so to speak.
I have an array of pointer properties, which are storing residential, and commercial buildings.
I would like to get 3 more functions working properly, and any heplful souls i will give more info if needed.

1) trying to delete a property:

void agency::remove_property()
{
property* p;
long p_id;

clrscr();
cout <<&quot;============== REMOVE A PROPERTY =================&quot; <<endl <<endl;
cout <<&quot;Enter the Property ID No. &quot;;
cin >> p_id;
p = find_prop (p_id);
p->show();
pause (&quot;Press any key to continue&quot;);
props[no_props] = p;
delete p;
p = props[no_props -1];
no_props --;
props[no_props] = NULL;

}
almost works however deletes the last stored property, and not the one i have entered the id for.

2)

The next one i want to display all residentials in-between two given input prices.
This doesnt work also but is nearly there:
void agency::disp_res_range()
{
int i;
long price;
long x;
long y;
clrscr();
cout <<&quot;============ SHOW RESIDENTIAL PROPERTIES ==============&quot; <<endl <<endl;

cout <<&quot;Enter lower value: &quot;<< endl;
//cin >> x;
cout <<&quot;Enter higher value: &quot;<< endl;
//cin >> y;
//(price >= x) && (price <= y))
for (i=0; i<no_props; ++i)
{

if ((props->get_r_range() == 1)) //&& ((price > x) & (price < y)))
{
clrscr();
cout <<&quot;RESIDENCIES &quot; <<i <<endl;
props->show();
pause (&quot;Press any key to show next PROPERTY&quot;);
}
}
clrscr();
pause (&quot;END OF UNSOLD PROPERTIES LIST - press any key to return to menu&quot;);
}
Thanks in advance, i will love it if anyone helps!


 
The find property function is returning the last pid.

I would think that you would look in this function for the error.


this looks suspicious. and I suspect will clear the last property regardless of the results of the previous code.

p = props[no_props -1];
no_props --;
props[no_props] = NULL;

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top