鱼C论坛

 找回密码
 立即注册
查看: 2612|回复: 1

编译没问题,链接出了问题,想请教各位哪出了问题

[复制链接]
发表于 2016-4-7 21:49:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. //Compare.h
  2. template <class numtype>
  3. class Compare
  4. {
  5.   public :
  6.           Compare(numtype a,numtype b);
  7.           numtype max ();
  8.       numtype min ();
  9.   private :
  10.           numtype x,y;
  11. };
  12. //Compare.cpp
  13. # include <iostream>
  14. # include "Compare.h"
  15. template <class numtype>
  16. numtype Compare <numtype>::max ()
  17. {
  18.         return (x>y)?x:y;
  19. }
  20. template <class numtype>
  21. numtype Compare <numtype>::min ()
  22. {
  23.         return (x<y)?x:y;
  24. }
  25. // main.cpp
  26. # include <iostream>
  27. # include "Compare.h"
  28. using namespace std;
  29. int main()
  30. {
  31. Compare <int>cmp1(3,7);
  32. cout<<cmp1.max()<<" is the maximum of two integer numbers ."<<endl;
  33. cout <<cmp1.min()<<" is the minimum of two integer numbers ."<<endl;


  34. Compare <float> cmp2(45.78,93.6);
  35. cout <<cmp2.max()<<" is the maximum of two integer numbers ."<<endl;
  36. cout <<cmp2.min()<<" is the minimum of two integer numbers ."<<endl;


  37. Compare <char>cmp3 ('a','A');
  38. cout <<cmp3.max()<<" is the maximum of two characteres ."<<endl;
  39. cout <<cmp3.min()<<" is the minimum of two characteres ."<<endl;
  40. return 0;
  41. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2016-4-11 15:06:27 | 显示全部楼层
有没有人会啊,教教我吧,搞不懂哪错了,链接显示类似以下错误
main.obj : error LNK2001: unresolved external symbol "public: char __thiscall Compare<char>::min(char,char)" (?min@?$Compare@D@@QAEDDD@Z)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-22 08:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表