Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to load and display 8bit gray scale image Pin
Omar Alvi28-May-04 0:45
Omar Alvi28-May-04 0:45 
GeneralDatabase Application Design Pin
asv28-May-04 0:28
asv28-May-04 0:28 
GeneralRe: Database Application Design Pin
valikac28-May-04 14:00
valikac28-May-04 14:00 
GeneralRe: Database Application Design Pin
asv28-May-04 15:25
asv28-May-04 15:25 
Generalvisual c++ help hanging Pin
crazymike193828-May-04 0:27
crazymike193828-May-04 0:27 
GeneralRe: visual c++ help hanging Pin
jmkhael28-May-04 0:58
jmkhael28-May-04 0:58 
GeneralTaskbar icon mouse messages and keyboard modifiers Pin
cheesepirate28-May-04 0:24
cheesepirate28-May-04 0:24 
QuestionFunction template passed as typename argument? Pin
Indrawati28-May-04 0:12
Indrawati28-May-04 0:12 
Hi I just recently learned about templates in C++, and I find it very useful and simple to use. I have one question though on a (possibly toy) problem.

Let's say I have the following declarations:

int maxint(int o1, int o2) {return (o1 > o2 ? o1 : o2);}

template <typename arg, typename T>arg Fun(arg i1, arg i2, T func)
{
return func(i1, i2);
}

and I invoke Fun in main() as follows:

cout << Fun(a, b, maxint) << endl;

where a and b are integers. This compiles and works without any error. But let's say I want to generalize maxint, and I create the following function template:

template <typename T>T maxi(T o1, T o2){return (o1 > o2 ? o1: o2);}

The linker always complains about unresolved external symbol "int __cdecl maxi(int,int)" when I tried to invoke maxi in main() with the following:

cout << Fun(a, b, maxi<int>) << endl;

Could anyone tell me what I did wrong, and how I can rectify it? Thanks!
AnswerRe: Function template passed as typename argument? Pin
Ryan Binns28-May-04 0:53
Ryan Binns28-May-04 0:53 
AnswerRe: Function template passed as typename argument? Pin
cheesepirate28-May-04 0:53
cheesepirate28-May-04 0:53 
GeneralRe: Function template passed as typename argument? Pin
toxcct28-May-04 1:10
toxcct28-May-04 1:10 
GeneralRe: Function template passed as typename argument? Pin
cheesepirate28-May-04 2:23
cheesepirate28-May-04 2:23 
AnswerRe: Function template passed as typename argument? Pin
toxcct28-May-04 1:12
toxcct28-May-04 1:12 
GeneralProblem subclassing list of owner-drawn combobox Pin
Paul Vickery27-May-04 23:46
professionalPaul Vickery27-May-04 23:46 
GeneralRe: Problem subclassing list of owner-drawn combobox Pin
Paul Vickery28-May-04 1:22
professionalPaul Vickery28-May-04 1:22 
QuestionHow to save GDI+ bmp as CMYK color GDI+ bmp Pin
pubududilena27-May-04 23:44
pubududilena27-May-04 23:44 
Questionchar* arr = &#8220;Nisse&#8221;; ? Pin
anderslundsgard27-May-04 23:34
anderslundsgard27-May-04 23:34 
AnswerRe: char* arr = &#8220;Nisse&#8221;; ? Pin
Roger Allen27-May-04 23:38
Roger Allen27-May-04 23:38 
AnswerRe: char* arr = &#8220;Nisse&#8221;; ? Pin
toxcct27-May-04 23:38
toxcct27-May-04 23:38 
AnswerRe: char* arr = &#8220;Nisse&#8221;; ? Pin
jmkhael28-May-04 0:55
jmkhael28-May-04 0:55 
Answer[Message Deleted] Pin
Naren Neelamegam28-May-04 19:58
Naren Neelamegam28-May-04 19:58 
GeneralRe: char* arr = &#8220;Nisse&#8221;; ? Pin
toroso7328-May-04 21:04
toroso7328-May-04 21:04 
GeneralExperts pls help ! General question Pin
Member 115017627-May-04 21:49
Member 115017627-May-04 21:49 
Generalfullscreen dialog control Pin
Bilge Kaan27-May-04 21:30
Bilge Kaan27-May-04 21:30 
GeneralRe: fullscreen dialog control Pin
Ryan Binns28-May-04 0:57
Ryan Binns28-May-04 0:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.