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!

Can't use template function to do two similar things(display member,bo

Status
Not open for further replies.

grscot

Programmer
Apr 25, 2003
16
GR
Dear all,

In the menu, I can add members in a memberlist and display them, using the function :
template<class Object>
void List<Object>::displayElement(char* type)
{
if (num_elements == 0)
cout<<&quot;No &quot;<<type<<&quot; is found in the &quot;<<type<< &quot;array.\n&quot;;
else
for(int element=0; element<this->num_elements; element++)
{
cout<<'\n';
this->element_list[element]->display(association_list.get_member(element_list[element]));
}
}

The problem is that I want to use the same function to display also the books, but there is a problem about the type of the argument of get_member() function. That function accepts only class Book* argument and not class Member* argument. The latter one is necessary to display the books.

How can I avoid this problem and use the same function to display both the books and members without any problems?

If code is required to answer my question, let me know about it.


Regards,
grscot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top