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

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 閱讀(464) 評論(0)  編輯 收藏 引用 所屬分類: Template
<2010年5月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用鏈接

留言簿(10)

隨筆分類(307)

隨筆檔案(297)

algorithm

Books_Free_Online

C++

database

Linux

Linux shell

linux socket

misce

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

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>
            久久久在线视频| 国产精品v欧美精品∨日韩| 国产精品久久久久永久免费观看| 亚洲欧美中文字幕| 午夜精品久久久久久99热软件| 亚洲激情视频在线播放| 国产一区二区在线观看免费播放| 国产精品免费一区豆花| 欧美色综合天天久久综合精品| 亚洲一区二区三区精品视频 | 国产精品v欧美精品v日本精品动漫| 久久久噜噜噜久久| 美玉足脚交一区二区三区图片| 久久久久久久久久久久久女国产乱 | 亚洲一区欧美| 欧美亚洲一区二区在线| 亚洲一区二区在线播放| 久久av在线看| 另类欧美日韩国产在线| 久久精品人人爽| 欧美欧美在线| 欧美性视频网站| 在线欧美不卡| 一级日韩一区在线观看| 久久精品观看| 女人天堂亚洲aⅴ在线观看| 日韩视频在线一区| 小黄鸭视频精品导航| 久久精品在线| 欧美日韩xxxxx| 国产欧美日韩精品专区| 亚洲精品久久久久中文字幕欢迎你| 一本大道久久精品懂色aⅴ| 久久久久久网址| 欧美激情一级片一区二区| 亚洲影视在线| 麻豆精品在线视频| 欧美成人精品在线视频| 欧美色视频在线| 国产视频一区在线观看一区免费| 亚洲国产日韩精品| 亚洲一级在线观看| 性做久久久久久久免费看| 欧美大成色www永久网站婷| 欧美一区二粉嫩精品国产一线天| 久久阴道视频| 9人人澡人人爽人人精品| 欧美中文字幕在线观看| 欧美精品国产一区二区| 国产手机视频一区二区| 亚洲美女电影在线| 欧美一区二视频| 日韩一级黄色片| 中文亚洲欧美| 性欧美video另类hd性玩具| 国产精品手机在线| 91久久精品网| 久久久久欧美| 一本色道久久综合亚洲精品不| 亚洲国产成人久久综合一区| 亚洲男人影院| 久久精品一区| 欧美精品综合| 亚洲电影视频在线| 久久久精品日韩| 中文国产亚洲喷潮| 欧美精品一区视频| 亚洲高清免费在线| 久久午夜精品| 日韩视频在线播放| 欧美在线91| 欧美福利在线观看| 在线日韩中文| 玖玖在线精品| 欧美一二区视频| 欧美激情视频一区二区三区免费| 樱桃国产成人精品视频| 久久av二区| 欧美一级免费视频| 国产在线高清精品| 久久偷窥视频| 久久久久久久尹人综合网亚洲| 国产伦精品一区二区三区四区免费 | 欧美在线不卡视频| 老鸭窝毛片一区二区三区| 欧美一区二区视频在线观看2020| 国产精品视频| 欧美综合国产精品久久丁香| 午夜欧美电影在线观看| 国产日韩欧美在线| 中日韩高清电影网| 中文av字幕一区| 国产一区视频观看| 欧美成ee人免费视频| 欧美黑人在线播放| 亚洲尤物在线视频观看| 亚洲综合电影| 国内精品国语自产拍在线观看| 毛片一区二区| 欧美日产国产成人免费图片| 亚洲在线视频网站| 欧美一区二区视频97| 亚洲春色另类小说| 久久综合图片| 免费在线看成人av| 日韩视频一区二区三区在线播放| 亚洲开发第一视频在线播放| 欧美激情第9页| 香蕉精品999视频一区二区| 国产日韩欧美一区二区三区四区| 欧美+亚洲+精品+三区| 一区二区三区**美女毛片 | 欧美日韩午夜视频在线观看| 欧美一区二区三区喷汁尤物| 亚洲国产精品久久91精品| 欧美激情第4页| 久久尤物视频| 亚洲电影专区| 蜜臀久久久99精品久久久久久| 久久综合网络一区二区| 国产三区二区一区久久| 99精品视频网| 欧美激情精品久久久久久久变态| 性视频1819p久久| 中文在线资源观看网站视频免费不卡 | 亚洲先锋成人| 久久久久久综合网天天| 久久久久久久久蜜桃| 午夜亚洲激情| 亚洲欧美一区二区原创| 在线免费观看一区二区三区| 小辣椒精品导航| 欧美国产另类| 亚洲精品少妇30p| 亚洲视频二区| 美女图片一区二区| 欧美午夜视频在线观看| 免费不卡在线视频| 亚洲在线观看| 亚洲精品极品| 欧美成人按摩| 欧美激情亚洲国产| 久久久久综合网| 久久精品女人天堂| 夜夜嗨av色综合久久久综合网| 免费视频一区二区三区在线观看| 国产精品丝袜久久久久久app| 欧美日韩你懂的| 亚洲福利视频网站| 亚洲天堂网在线观看| 久久综合影音| 午夜视频在线观看一区二区| 欧美激情一区| 99视频精品| 亚洲高清在线观看一区| 在线观看91精品国产麻豆| 国产综合一区二区| 国产一区在线看| 亚洲国产精品成人精品| 中文日韩在线视频| 亚洲精品网站在线播放gif| 日韩视频专区| 午夜国产精品影院在线观看| 久久综合九九| 欧美激情一区二区三区四区| 亚洲乱码国产乱码精品精可以看| 在线综合+亚洲+欧美中文字幕| 久久久99精品免费观看不卡| 欧美日韩在线视频一区二区| 亚洲国产一区二区三区高清| 久久高清一区| 麻豆成人小视频| 9色porny自拍视频一区二区| 欧美一区观看| 一区二区不卡在线视频 午夜欧美不卡在| 亚洲欧洲在线播放| 日韩亚洲欧美一区| 免费观看成人www动漫视频| 欧美激情免费观看| 亚洲一区二三| 欧美国产专区| 久久久久久久91| 欧美成人亚洲| 久久综合国产精品| 亚洲国产精品小视频| 一区二区三区蜜桃网| 国产精品99久久久久久久女警| 国产精品久久久久久久久久久久| 国内精品美女在线观看| 亚洲专区在线| 一区二区三区高清| 国产精品久久久久av免费| 亚洲欧美日韩精品久久久久| 一区二区三区黄色| 国产精品久久久久99| 久久精品在线视频| 麻豆精品传媒视频| 亚洲欧美日韩另类精品一区二区三区| 欧美一级视频一区二区| 一区二区三区免费看|