Skip to main content
GameDev.net gamedev.net
🔒 Locked

Templated function pointer. . .

Started by acw83 Apr 20, 2002 at 9:27 AM 2 replies 700+ views
Original Post
acw83
acw83
Is there anyway I can do this in VC++.NET: template <class type> bool (*isGreater) (type data1, type data2); It is a function for a templated binary tree class. It it used to determine if a data memeber needs to go to the right or left. VC++.NET gives me the following error: error C2998: 'bool (__cdecl *__cdecl isGreater)(<template parameter>,<template parameter>)' : cannot be a template definition [Edit: board needs a little coaxing to show template definitions.] [edited by - Oluseyi on April 20, 2002 11:11:23 AM]
msn12b
msn12b
Embed the function pointer type in a template class:

template &ltclass type> class function_type
{
typedef bool (*isGreater)(type data1, type data2);
};

Then, reference via:

function_type&lttype_goes_here>::isGreater func= blah;

MSN
acw83
acw83
Thanks for the work around. Damn those Microsoft bastards.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.