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

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>
            欧美电影免费观看| 国产精品免费一区豆花| 亚洲国产视频a| 久久久精品欧美丰满| 久久国产精品亚洲77777| 香蕉乱码成人久久天堂爱免费| 亚洲视频一二区| 亚洲欧美日韩网| 欧美一站二站| 欧美成人免费va影院高清| 亚洲欧洲一区二区三区| 国产精品久久久久久久久久ktv | 日韩视频免费看| 一区二区三区精品视频| 亚洲一区在线观看免费观看电影高清| 亚洲欧美视频在线| 欧美成人a视频| 亚洲视频狠狠| 久久国产主播| 欧美人成网站| 国外成人网址| 国产精品99久久99久久久二8 | 在线观看欧美| 亚洲一区二区三区乱码aⅴ蜜桃女 亚洲一区二区三区乱码aⅴ | 国产欧美一区二区精品性色| 一区在线视频| 亚洲女优在线| 亚洲电影网站| 欧美亚洲日本国产| 欧美日韩亚洲激情| 一区免费观看视频| 亚洲欧美怡红院| 亚洲高清免费视频| 亚洲欧美日韩网| 欧美人成在线| 亚洲国产三级在线| 欧美在线日韩| 日韩午夜精品| 久久综合久久综合久久| 国产精品婷婷| 99视频在线观看一区三区| 久久综合色影院| 亚洲欧美中文字幕| 欧美日韩直播| 99国产精品久久久久久久成人热| 老司机久久99久久精品播放免费| 亚洲香蕉视频| 欧美性一区二区| 在线中文字幕日韩| 亚洲人午夜精品| 欧美激情综合色| 亚洲激情视频网| 老司机免费视频一区二区三区 | 欧美va亚洲va香蕉在线| 欧美亚洲综合久久| 国产欧美日韩综合一区在线播放| 中文欧美日韩| 一本色道久久加勒比精品| 欧美韩日亚洲| 亚洲精品乱码久久久久久按摩观| 你懂的一区二区| 美女网站久久| 亚洲精品一区二区三区99| 欧美肥婆在线| 欧美丰满少妇xxxbbb| 亚洲欧洲一级| 91久久在线播放| 欧美日韩国产在线播放网站| 在线中文字幕不卡| 亚洲一区二区三区精品在线 | 亚洲夜晚福利在线观看| 日韩午夜在线| 国产伦精品一区二区| 久久精品日产第一区二区| 欧美在线观看日本一区| 免费观看30秒视频久久| 新狼窝色av性久久久久久| 欧美精品免费看| 亚洲高清av在线| 欧美韩国一区| 亚洲欧美福利一区二区| 亚洲欧美国产va在线影院| 黑人中文字幕一区二区三区| 欧美88av| 欧美午夜在线一二页| 久久精品视频在线| 久久男人资源视频| 99国产精品久久久久久久成人热 | 亚洲小视频在线观看| 国产伦精品一区二区三区在线观看| 久久精品国产综合精品| 久久综合伊人| 亚洲小视频在线| 久久精品日韩欧美| 亚洲无线一线二线三线区别av| 亚洲欧美日韩国产综合| 亚洲国产精品ⅴa在线观看| 一区二区三区日韩在线观看| 精品动漫一区| 国产精品99久久久久久白浆小说| 一区二区三区在线免费播放| 宅男66日本亚洲欧美视频| 在线国产精品播放| 亚洲视频综合| 最新成人在线| 久久不见久久见免费视频1| 亚洲免费福利视频| 久久精品国产精品| 午夜精品一区二区三区四区 | 国产亚洲欧洲一区高清在线观看 | 久久夜色精品国产亚洲aⅴ| 欧美日韩精品久久久| 裸体一区二区| 国产精品男gay被猛男狂揉视频| 欧美黄色免费网站| 国内精品视频666| 亚洲综合成人在线| 在线综合欧美| 欧美精品二区| 亚洲国产精品第一区二区三区 | 欧美日韩国产精品一卡| 美女视频黄 久久| 国产中文一区二区| 午夜精品成人在线视频| 亚洲欧美另类在线| 欧美午夜a级限制福利片| 亚洲精品美女在线观看| 亚洲精品在线一区二区| 欧美成人免费观看| 亚洲欧美日韩综合| 久久蜜桃av一区精品变态类天堂| 国产精品成人va在线观看| 亚洲三级观看| 在线视频你懂得一区| 欧美日韩aaaaa| 日韩视频在线播放| 亚洲永久精品大片| 欧美日韩午夜剧场| 宅男噜噜噜66一区二区| 亚洲一区二区精品在线| 国产精品黄色在线观看| 亚洲永久免费观看| 午夜精品999| 国产精品成人久久久久| 国产精品99久久久久久久久 | 欧美韩日一区| 亚洲伦理自拍| 欧美性色综合| 欧美一区二区三区在线看| 麻豆免费精品视频| 亚洲卡通欧美制服中文| 欧美午夜不卡视频| 欧美一区二区三区在| 欧美激情网友自拍| 亚洲永久免费精品| 国产在线高清精品| 久久亚洲午夜电影| 91久久精品www人人做人人爽 | 1769国产精品| 欧美日产国产成人免费图片| 一区二区三区不卡视频在线观看| 午夜亚洲性色福利视频| 黄色成人精品网站| 欧美国产日韩精品| 亚洲欧美激情精品一区二区| 久热精品视频在线观看一区| 亚洲美女视频在线观看| 国产精品天天看| 免费成人毛片| 亚洲欧美精品伊人久久| 欧美福利一区二区三区| 午夜激情综合网| 亚洲国产精品一区二区久| 欧美日韩一区二区在线播放| 欧美一区影院| 日韩天堂av| 免费黄网站欧美| 亚洲无限av看| 亚洲国内欧美| 国产亚洲aⅴaaaaaa毛片| 欧美激情视频一区二区三区不卡| 香蕉成人啪国产精品视频综合网| 亚洲成色777777在线观看影院| 亚洲一区视频| 亚洲国内自拍| 韩国精品在线观看| 国产精品久久久久免费a∨| 另类天堂av| 欧美中在线观看| 中文亚洲欧美| 亚洲欧洲偷拍精品| 欧美成人午夜免费视在线看片| 香蕉成人伊视频在线观看 | 免费观看30秒视频久久| 亚洲在线视频免费观看| 亚洲美女视频网| 久久国产欧美| 国产精品乱人伦一区二区| 欧美大片在线看| 久久夜色精品国产亚洲aⅴ|