第11章-模板概述.pptVIP

  • 5
  • 0
  • 约1.03万字
  • 约 30页
  • 2016-11-29 发布于湖北
  • 举报
§11-3 类模板 templateclass T T* ListT::Find(T t) { for(Node* p=pFirst; p; p=p-pNext) if(*(p-pT)==t) return p-pT; return 0; } templateclass T void ListT::PrintList() { for(Node* p=pFirst; p; p=p-pNext) cout *(p-pT) ; //须处理T对象输出 coutendl; } templateclass T ListT::~List() { Node* p; while(p=pFirst){ pFirst = pFirst-pNext; delete p-pT; delete p; } pFirst = 0; } §11-3 类模板 #include listtmp.h void main() { Listfloat floatList; for(int i=1; i7; i++) floatList.Add(*new float(i+0.6)); floatList.PrintList(); float b=3.6; float* pa=floatList.Find(b); if(pa) floatList.Remo

文档评论(0)

1亿VIP精品文档

相关文档