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

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 閱讀(471) 評論(0)  編輯 收藏 引用 所屬分類: Template
<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用鏈接

留言簿(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>
            欧美激情aⅴ一区二区三区| 欧美日韩激情网| 激情综合自拍| 久久综合一区| 免费欧美网站| 中国成人黄色视屏| 亚洲一区二区三区四区在线观看| 国产精品久久久久久久午夜片| 亚洲综合99| 欧美一区二区三区久久精品| 国内外成人免费激情在线视频网站 | 亚洲视频免费看| 国产精品一区三区| 久久综合成人精品亚洲另类欧美 | 亚洲精品一区在线| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 久久精品99| 亚洲欧洲另类国产综合| 亚洲精品乱码久久久久久久久| 欧美日韩另类在线| 久久久99精品免费观看不卡| 蜜臀av性久久久久蜜臀aⅴ四虎| 9国产精品视频| 欧美在线影院在线视频| 亚洲精品欧美精品| 亚洲免费在线精品一区| 亚洲高清在线| 亚洲欧美日韩视频一区| 亚洲国产欧美一区二区三区同亚洲 | 最新国产成人av网站网址麻豆| 亚洲人体一区| 国产专区欧美专区| 一道本一区二区| 亚洲福利视频在线| 午夜电影亚洲| 日韩亚洲一区二区| 久久免费99精品久久久久久| 亚洲无毛电影| 欧美aaaaaaaa牛牛影院| 欧美在线视频一区二区三区| 欧美精品成人| 欧美成人高清视频| 国产亚洲欧美一级| 亚洲最新视频在线播放| 亚洲国产精品女人久久久| 亚洲欧美在线看| 亚洲天堂av在线免费| 欧美不卡高清| 男女av一区三区二区色多| 国产欧美1区2区3区| 亚洲看片网站| 日韩午夜在线观看视频| 久久久中精品2020中文| 久久九九全国免费精品观看| 欧美视频四区| 一本一本久久a久久精品综合妖精 一本一本久久a久久精品综合麻豆 | 欧美1区2区视频| 久久尤物视频| 激情欧美日韩一区| 欧美一区激情| 久久精品免费| 国产精品网站在线| 正在播放亚洲一区| 亚洲综合国产| 国产精品毛片a∨一区二区三区|国 | 亚洲国产精品一区二区www| 伊人久久噜噜噜躁狠狠躁| 久久av一区二区三区亚洲| 久久精品一区二区三区中文字幕| 国产精品私拍pans大尺度在线| 一区二区三区视频在线| 亚洲一区二区三区视频播放| 欧美日韩在线精品| 一区二区三区免费观看| 亚洲欧美日韩成人高清在线一区| 国产精品成人观看视频免费 | 久久久久一区二区| 红桃视频成人| 欧美jizz19性欧美| 亚洲另类黄色| 午夜精品视频在线观看一区二区| 国产麻豆午夜三级精品| 欧美在线观看视频一区二区| 蜜臀久久99精品久久久久久9| 亚洲国产成人在线播放| 噜噜噜91成人网| 日韩一区二区福利| 欧美一区二区三区男人的天堂 | 樱花yy私人影院亚洲| 久久资源av| 日韩天堂在线视频| 欧美一区二区三区四区在线观看地址| 国产精品一区二区三区成人| 久久久久国色av免费看影院| 亚洲人成人99网站| 欧美一区二区三区免费视频| 亚洲国产精品999| 欧美日韩免费在线观看| 香蕉尹人综合在线观看| 欧美成人免费在线观看| 在线亚洲精品| 一区二区在线看| 欧美日韩专区| 久久一区精品| 亚洲制服少妇| 亚洲风情在线资源站| 欧美一区日韩一区| aaa亚洲精品一二三区| 国产亚洲美州欧州综合国| 欧美国产免费| 久久久精品动漫| 亚洲午夜激情网站| 最新国产成人在线观看| 久久精品国产99| 中文国产一区| 亚洲激情影视| 激情久久综合| 国产亚洲亚洲| 国产精品啊啊啊| 欧美精品不卡| 免费久久99精品国产自| 欧美亚洲自偷自偷| 亚洲桃花岛网站| 日韩视频三区| 亚洲高清在线播放| 免费成人网www| 久久久久久久91| 欧美一区观看| 亚洲欧美日韩综合一区| 一本到高清视频免费精品| 在线观看日产精品| 黑人一区二区三区四区五区| 国产精品一区二区你懂得| 欧美日韩美女一区二区| 欧美国产一区在线| 免费欧美电影| 免费观看在线综合| 久久久久综合| 久久精品人人做人人综合| 亚洲欧美激情一区二区| 亚洲午夜视频| 亚洲女人天堂成人av在线| 亚洲深夜福利视频| 亚洲一区二区三区四区中文| aⅴ色国产欧美| 亚洲视频视频在线| 亚洲欧美日韩一区在线| 亚洲一区二区在线播放| 亚洲一区亚洲二区| 欧美在线观看网址综合| 欧美在线免费一级片| 久久国产福利| 久久综合免费视频影院| 蜜臀久久99精品久久久画质超高清 | 亚洲一区二区三区视频播放| 99精品视频免费观看| 一二三区精品| 亚洲欧美一区二区三区久久| 小处雏高清一区二区三区 | 欧美成人免费全部| 亚洲高清资源| 一区二区毛片| 香蕉久久夜色精品国产使用方法| 欧美影视一区| 免费在线观看一区二区| 欧美日韩国产高清| 国产精品视频网站| 一区二区在线观看视频| 亚洲日本免费| 午夜欧美视频| 老司机精品视频一区二区三区| 欧美激情精品久久久久久免费印度 | 欧美福利视频网站| 亚洲精品女人| 亚洲视频网在线直播| 西瓜成人精品人成网站| 美女精品在线观看| 国产精品久久久久久久久久免费 | 亚洲免费av电影| 亚洲欧美日本伦理| 男人的天堂亚洲在线| 99综合在线| 久久美女艺术照精彩视频福利播放| 欧美激情a∨在线视频播放| 国产精品久久久久久久久免费 | 一本色道久久88综合亚洲精品ⅰ| 亚洲已满18点击进入久久| 久久久亚洲高清| 一本综合久久| 美女国产一区| 国产一区二区0| 亚洲系列中文字幕| 亚洲成色777777在线观看影院| 亚洲特级毛片| 欧美激情四色 | 国产亚洲观看| 亚洲一区二区三区三| 欧美国产日韩免费| 性欧美xxxx视频在线观看| 欧美日本中文字幕|