免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1679 | 回复: 2
打印 上一主题 下一主题

编译警告:Instantiated from non-template code [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-10-20 15:17 |只看该作者 |倒序浏览
虽然是warning,还是不爽啊


出错的程序:

  1. class SymbolTable
  2. {
  3.        
  4.         public:
  5.                 SymbolTable();
  6.                 SymbolTable(const char[]);                // name of file
  7.                 void File(const char[]);                // connect file
  8.                 ~SymbolTable();
  9.                 void Make();
  10.                 void Print();
  11.         private:
  12.                 Program Prog;
  13.                 BinaryTree<WordPtr>; ST;
  14. };
复制代码

  1. void SymbolTable::Make()
  2. {
  3.         //        Using the function GetNextToken from the Program class
  4.         //        set up a loop that gets the next token and, if it is not
  5.         //        already in the binary tree ST, inserts it.
  6.         //        Use Locate to test if the item already exists.
  7.         int line=0;
  8.         char* word;
  9.         WordPtr wd1, wd2;
  10.        
  11.         //
  12.         Program rserrved;
  13.         rserrved.Open("ReservedWords.txt");

  14.         while(1)
  15.         {
  16.                 word=new char[30];
  17.                 if (!rserrved.GetNextToken(word, line)){
  18.                         delete[] word;
  19.                         break;
  20.                 }
  21.                 wd1 = new ReservedWord(word);
  22.                 ST.Insert(wd1);
  23.                 word=new char[30];
  24.         }

  25.        
  26.         while(1)
  27.         {
  28.                 word=new char[30];
  29.                 if (!Prog.GetNextToken(word, line)){
  30.                         delete[] word;
  31.                         break;
  32.                 }
  33.                 wd1 = new Identifier(word);
  34.                 wd1->;Update(line);
  35.                 if (ST.Locate(wd1, wd2))
  36.                 {
  37.                         delete[] word;
  38.                         delete wd1;
  39.                         wd2->;Update(line);
  40.                 }
  41.                 else
  42.                 {
  43.                         ST.Insert(wd1);
  44.                 }
  45.         }
  46. }

  47. void SymbolTable::Print()
  48. {
  49.         //        Set up a BinaryTreeIterator attached to the tree ST
  50.         //        and loop through the tree, using Print to display
  51.         //        what each pointer in the tree points at
  52.         BinaryTreeIterator< WordPtr >; iter(ST);
  53.        
  54.         iter.SetIterator();
  55.         while (iter.More())
  56.         {
  57.                 iter.Next()->;Print(cout);
  58.         }
  59. }
复制代码


这两句有问题,而且都是 "Where: Instantiated from non-template code"

//                ST.Insert(wd1);
//                if (ST.Locate(wd1, wd2))



相关的代码

  1. template <class T>;
  2. class BinaryTree
  3. {
  4.         friend class BinaryTreeIterator<T>;;
  5.        
  6.         public:
  7.                 BinaryTree();
  8.                 ~BinaryTree();
  9.                 void Insert(const T&);
  10.                 bool Locate(const T&, T&);
  11.                 bool Delete(const T&, T&);

  12.                 struct node;
  13.                 typedef node *nodePtr;
  14.                 struct node
  15.                 {
  16.                         T data;
  17.                         nodePtr left, right, parent;
  18.                 };               
  19.         private:
  20.                 nodePtr root;
  21.                
  22.                 nodePtr FindNode(const T&, nodePtr);
  23.                 void InsertNode(const T&, nodePtr&);
  24.                 void PostOrderDelete(nodePtr);
  25. };
复制代码

  1. template<class T>;
  2. void BinaryTree<T>;::Insert(const T& data)
  3. {
  4.         InsertNode(data, root);
  5. }

  6. template<class T>;
  7. bool BinaryTree<T>;::Locate(const T& data, T& founddata)
  8. {
  9.         nodePtr foundNode = FindNode(data, root);
  10.        
  11.         if (foundNode != 0)
  12.         {
  13.                 founddata = foundNode->;data;
  14.                 return true;
  15.         }
  16.         else
  17.                 return false;

  18. }
复制代码

论坛徽章:
0
2 [报告]
发表于 2005-10-20 15:34 |只看该作者

编译警告:Instantiated from non-template code

哪位大侠能给解释一下这个警告的具体含义。。。。。。

论坛徽章:
0
3 [报告]
发表于 2006-11-23 13:39 |只看该作者

回复 2楼 bigfatsea 的帖子

同问,这个警告是什么意思该怎么消除呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP