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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Templated function with function pointers

Status
Not open for further replies.

jstreich

Programmer
Apr 20, 2002
1,067
US
I have a global function, as follows:

Code:
template <class thing>
vector< pair<size_t,Loan> > 
Sort(Vector< pair<size_t,Loan> v, thing (Loan::* by)());

defined and protyped in a Repository class (a supped up container class)... And the interface is calling the function

Code:
vector< pair<size_t,Loan> > loans = repository.getLoans();
loans = Sort<string>(loans,&Loan.getLoanID);
Loan::getLoanID returns a string. Both classes compile into objects, but there is a linking error (symbol Referencing error)... Any thoughts on why it won't link would be appreciated.
 
Try passing &Loan::getLoanID instead of &Loan.getLoanID.

I'm not sure why your compiler would have passed the dot notation... it must mean something weird I don't know about.

Since Loan is a class, not an object, you can't use the dot notation, and even if you had a Loan object called loan1, &loan1.getLoanID wouldn't make sense to the compiler since there's only the one member function, not one per object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top