关于函数模板与类模板的初步认识

<span style="font-size:18px;">//函数模板</span>
<span style="font-size:18px;">template <class charT, class traits>
  basic_ostream<charT,traits>& endl ( basic_ostream<charT,traits>& os );</span>
<span style="font-size:18px;">//类模板</span>
<span style="font-size:18px;">template <class char T,class traits></span>
<span style="font-size:18px;">class basic_ostream</span>
<span style="font-size:18px;">{</span>
<span style="font-size:18px;">
</span>
<span style="font-size:18px;">}</span>
<span style="font-size:18px;">//模板函数是函数模板的具体实现</span>
<span style="font-size:18px;">//模板类是类模板的具体实现,类是对象的抽象,类模板是类的抽象;</span>
<span style="font-size:18px;">//模板的引入提高了可移植性,模板本身与平台无关;类型无关保证了很高的可复用性;在编译时而不是运行时检查数据类型,保证了类型安全、</span>
<span style="font-size:18px;">//可以来创建动态增长和减小的数据结构</span>
// (1) delimiter as parameter
 template<class CharType, class Traits, class Allocator> 
basic_istream<CharType, Traits>& getline(     basic_istream<CharType, Traits>& is,     basic_string<CharType, Traits, Allocator>& str, CharType delim); 

 template<class CharType, class Traits, class Allocator> 
basic_istream<CharType, Traits>& getline(     basic_istream<CharType, Traits>&& is,     basic_string<CharType, Traits, Allocator>& str, const CharType delim);  

// (2) default delimiter used
 template<class CharType, class Traits, class Allocator>
 basic_istream<CharType, Traits>& getline(     basic_istream<CharType, Traits>& is,     basic_string<CharType, Traits, Allocator>& str); 

 template<class Allocator, class Traits, class Allocator> 
basic_istream<Allocator, Traits>& getline(     basic_istream<Allocator, Traits>&& is,     basic_string<Allocator, Traits, Allocator>& str);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值