青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 297,  comments - 15,  trackbacks - 0
If we want to define a different implementation for a template when a specific type is passed as template parameter, we can declare a specialization of that template.

For example, let's suppose that we have a very simple class called mycontainer that can store one element of any type and that it has just one member function called increase, which increases its value. But we find that when it stores an element of type char it would be more convenient to have a completely different implementation with a function member uppercase, so we decide to declare a class template specialization for that type:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// template specialization
#include <iostream>
using namespace std;

// class template:
template <class T>
class mycontainer {
T element;
public:
mycontainer (T arg) {element=arg;}
T increase () {return ++element;}
};

// class template specialization:
template <>
class mycontainer <char> {
char element;
public:
mycontainer (char arg) {element=arg;}
char uppercase ()
{
if ((element>='a')&&(element<='z'))
element+='A'-'a';
return element;
}
};

int main () {
mycontainer<int> myint (7);
mycontainer<char> mychar ('j');
cout << myint.increase() << endl;
cout << mychar.uppercase() << endl;
return 0;
}
8
J


This is the syntax used in the class template specialization:

 
template <> class mycontainer <char> { ... };


First of all, notice that we precede the class template name with an empty template<> parameter list. This is to explicitly declare it as a template specialization.

But more important than this prefix, is the <char> specialization parameter after the class template name. This specialization parameter itself identifies the type for which we are going to declare a template class specialization ( char). Notice the differences between the generic class template and the specialization:

1
2
template <class T> class mycontainer { ... };
template <> class mycontainer <char> { ... };


The first line is the generic template, and the second one is the specialization.

When we declare specializations for a template class, we must also define all its members, even those exactly equal to the generic template class, because there is no "inheritance" of members from the generic template to the specialization.

from:
http://www.cplusplus.com/doc/tutorial/templates/

posted on 2010-05-03 22:11 chatler 閱讀(469) 評論(0)  編輯 收藏 引用 所屬分類: Template
<2009年7月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用鏈接

留言簿(10)

隨筆分類(307)

隨筆檔案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

  • cloudward
  • 感覺這個博客還是不錯,雖然做的東西和我不大相關,覺得看看還是有好處的

network

OSS

  • Google Android
  • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
  • os161 file list

overall

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            一本到12不卡视频在线dvd| 欧美视频一区二区三区四区| 午夜亚洲福利在线老司机| 国产一区二三区| 欧美日韩美女| 欧美精品久久久久久久免费观看| 亚洲欧美另类在线| 亚洲精品免费在线观看| 亚洲一区二区在线看| 亚洲毛片一区二区| 这里只有精品电影| 亚洲美女黄色| 亚洲最黄网站| 欧美亚洲网站| 久久天天躁狠狠躁夜夜av| 99视频精品全部免费在线| 久久国产视频网站| 亚洲男女自偷自拍图片另类| 国模私拍视频一区| 国产精品分类| 亚洲国产精品久久精品怡红院| 一本色道久久综合狠狠躁篇的优点| 亚洲一区二区在线看| 香蕉亚洲视频| 亚洲伦理网站| 免费观看成人鲁鲁鲁鲁鲁视频| 国产精品海角社区在线观看| 日韩一级精品| 欧美中文字幕在线| 亚洲特级毛片| 国产精品国产三级国产| 亚洲精品永久免费精品| 久久综合网hezyo| 午夜久久黄色| 国内精品久久久| 久久久天天操| 久久手机免费观看| 国产亚洲精品一区二555| 亚洲欧美色婷婷| 一本大道久久精品懂色aⅴ| 欧美成人xxx| 日韩视频精品在线观看| 亚洲精品免费电影| 欧美激情导航| 午夜一区二区三区在线观看| 午夜欧美精品| 欧美日韩精品在线播放| 在线视频精品一| 午夜精品一区二区在线观看 | 午夜免费在线观看精品视频| 国产亚洲欧美一区二区三区| 欧美日韩综合久久| 宅男精品视频| 久久不射电影网| 一区二区三区高清| 亚洲欧美日韩视频一区| 亚洲电影在线免费观看| 中文日韩在线| 日韩视频一区二区在线观看| 午夜在线播放视频欧美| 狠狠88综合久久久久综合网| 欧美肥婆在线| 国产精品婷婷| 日韩视频中文| 亚洲人成网在线播放| 午夜一区在线| 欧美一区国产在线| 国产精品亚洲一区| 亚洲二区在线视频| 国产精品久久久久久福利一牛影视 | 亚洲一区区二区| 快播亚洲色图| 欧美成人三级在线| 国产真实乱子伦精品视频| 国产精品99久久久久久久vr| 亚洲风情亚aⅴ在线发布| 亚洲男人av电影| 欧美在线播放高清精品| 国产午夜精品福利| 久久午夜电影| 久久久久久电影| 久久久久国色av免费看影院| 亚洲一区欧美二区| 国产精品久久91| 亚洲欧美日韩中文在线制服| 久久久国产一区二区| 亚洲视频中文| 久久久久久伊人| 激情综合色丁香一区二区| 久热爱精品视频线路一| 亚洲美女中文字幕| 午夜在线精品| 999在线观看精品免费不卡网站| 欧美日韩在线免费| 亚洲欧美一区二区三区久久| 欧美成人精品影院| 日韩视频在线观看免费| 国产日韩亚洲欧美| 欧美日本中文| 免费亚洲一区| 久久精品国产免费| 亚洲欧美日韩一区二区在线| 欧美bbbxxxxx| 久久久国际精品| 亚洲专区欧美专区| 日韩亚洲欧美成人一区| 亚洲电影在线| 在线观看日韩www视频免费 | 香蕉久久夜色精品国产使用方法| 亚洲大片精品永久免费| 久久精品电影| 久久精品系列| 久久精品99| 美国三级日本三级久久99| 久久久久se| 久久精品视频免费| 99国产精品99久久久久久| 国产精品免费aⅴ片在线观看| 久久综合网hezyo| 欧美不卡高清| 欧美欧美在线| 国产精品成人一区二区三区夜夜夜 | 欧美激情无毛| 欧美日本在线播放| 国产精品爱啪在线线免费观看| 国产精品高潮粉嫩av| 国产欧美在线观看| 亚洲成色精品| 亚洲欧美精品伊人久久| 久久一区二区视频| 99成人在线| 久久久久久电影| 国产精品jvid在线观看蜜臀| 在线观看日韩专区| 亚洲欧美电影在线观看| 麻豆成人精品| 亚洲免费观看视频| 久久久久久久一区| 国产精品日韩欧美一区二区三区| 国产字幕视频一区二区| 亚洲免费中文| 亚洲精品免费在线观看| 亚洲欧美日韩人成在线播放| 欧美激情按摩在线| 国产日产欧美一区| 午夜精品久久久久久久99黑人| 欧美激情视频网站| 久久综合狠狠综合久久激情| 国产一区二区三区在线观看免费视频| 亚洲精品专区| 亚洲精品国产系列| 欧美精品1区2区| 亚洲精品乱码久久久久久蜜桃麻豆 | 欧美3dxxxxhd| 亚洲高清二区| 久久久精彩视频| 一区电影在线观看| 亚洲日本欧美天堂| 午夜视频一区| 亚洲欧美福利一区二区| 一本一本a久久| 久久免费高清视频| 久久aⅴ乱码一区二区三区| 亚洲欧美日韩网| 99爱精品视频| 在线成人激情黄色| 久久精品国产2020观看福利| 久久久精品日韩| 99re6这里只有精品| 亚洲国产精品第一区二区三区| 国内成人自拍视频| 最新亚洲激情| 一本到高清视频免费精品| 欧美人与禽猛交乱配视频| 亚洲精品一区二区三区不| 亚洲电影免费观看高清| 欧美电影在线免费观看网站| 亚洲免费一级电影| 久久免费视频网| 亚洲午夜免费福利视频| 久久久精品999| 亚洲香蕉伊综合在人在线视看| 性8sex亚洲区入口| 99国产精品自拍| 久久综合九色综合欧美就去吻| 亚洲激情电影在线| 久久国产88| 欧美一乱一性一交一视频| 免费人成精品欧美精品| 久久精品欧美日韩| 国产目拍亚洲精品99久久精品| 欧美激情aaaa| 一区二区三区在线高清| 亚洲一区二区三区在线看| 亚洲毛片一区二区| 欧美黄免费看| 在线亚洲电影| 久久精品青青大伊人av| 国产欧美va欧美va香蕉在| 久久gogo国模裸体人体|