By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

Search function

P: n/a
Thanks for the help in my previous thread, I was able to solve the problem
by using some code I'd written into another function. For anyone interested
I've included the working code in my last thread.

I've now written some similar code to search for the winner of a race. The
"entries" in the code below is a pointer to an Entry. Below is the code I've
written to search for the winner, which works by checking if (Pl == 1);
however, I'm not sure how to implement this correctly. Further below my non
functioning code is a copy of the constructor I've used in the Entry class.
Could someone please have a look at my if/else function and advise where I'm
going wrong.

Thanks for any help.

void Race::winner (ostream& out) const

{

if (nEntries == 0) //nEntries is initialised to zero in the constructor

{

out << "No entries" << endl;

}

else

{

for (int i=0; i<nEntries; i++)

if (Pl == 1) //This is where I need help ..... I think....

{

out << *(entries[i]);

}

else

{

cout << "There was no winner in this race" << endl;

}

}

}

// Constructor from Entry class

Entry::Entry (Race* r, Yacht* y, int pl, string ti)

{

which = r;

what = y;

place = pl;

time = ti;

}


Jul 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.