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

健康,快樂,勇敢的寧帥!!

努力、努力、再努力! 沒有什么能阻止我對知識的渴望。

 

"C++Templates The Complete Guide"讀書筆記----Chapter 7

Basic Template Terminology
1. "Class Template" or "Template Class"?
class template: the class is a template.
template class: a synonym(同義詞) for class template; to refer to classes generated from templates(由模板產生(實例化)的類). to refer to classes with a name that is a template-id.
Because of this imprecision, template class is avoided in this book.

2. Instantiation and specialzation
Instantiation: 實例化. The process of creating a regular class, function, or member function from a template by substituting actual values for its arguments is called template instantiation.
Specialzation:特例,在Chapter 3中有描述

3. Declarations vs Definitions
declaration is a C++ construct that introduces or reintroduceds a name into? a C++ scope.
class?C;?//?a?declaration?of?C?as?a?class
void?f(int?p);?//?a?declaration?of?f()?as?a?function?and?p?as?a?named?parameter
extern?int?v;?//?a?declaration?of?v?as?a?variable

Declarations become definitions when the details of their structure are made known or, in the case of variables, when storage space must be allocated.
class?C{};?//?definition(and?declaration)?of?class?C
void?f(int?p){?//?defini
???std::cout<<?p?<<?std::endl;
}


extern?int?v?=?1;??//?an?initializer?makes?this?a?definition?for?v

int?w;???//?global?variable?declaration?not?preceded?by?extern?are?also?definitions
By extension, the declaration of?a class template or function template is called a definition if it has a body, Hence,
template?<typename?T>
void?func(T);
is a declaration that is not a definition, whereas
template?<typename?T>
class?S{};
is in fact a definition

posted @ 2006-12-03 15:02 ningfangli 閱讀(114) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 6

Using Templates in Practice

1. Templates challenge the classic compiler-plus-linker model. Therefore there are different approaches to organize template code: the inclusion model, explicit instantiation, and the separation model
Most C and C++ programmers organize their nontemplate code largely as follows:
1) Classes and other types are entirely placed in header files.
2) For global variables and (noninline) functions, only a declaration is put in a header file, and the definition goes into a so-called dot-C file.
The works well: It makes the needed type definition easily available throughout the program and avoids duplicate definition errors on variables and functions from the linker.
With the convention in mind, we declare the template in a header file:
#ifndef?MYFIRST_HPP
#define?MYFIRST_HPP

//?declaration?of?template
template?<typename?T>?
void?print_typeof?(T?const&);

#endif?//?MYFIRST_HPP
The implementation of the function is placed in a dot-C file:
#include?<iostream>
#include?
<typeinfo>
#include?
"myfirst.hpp"

//?implementation/definition?of?template
template?<typename?T>
void?print_typeof?(T?const&?x)
{
????std::cout?
<<?typeid(x).name()?<<?std::endl;
}
Finally, we use the template in another dot-C file, into which our template declaration is #include:
#include?"myfirst.hpp"

//?use?of?the?template
int?main()
{
????
double?ice?=?3.0;
????print_typeof(ice);??
//?call?function?template?for?type?double
}

A C++ compiler will most likely accept this program without any problems,but the linker will probably report an error, implying that there is no definition of the function print_typeof().
In order for a template to be? instantiated, the compiler must know which definition should be instantiated and for what template arguments it should be instantiated. Unfortunately, these two pieces of information are in files that are compiled separatedly. Therefore, when our compiler sees the call to print_typeof() but has no definition in sight to instantiate this function for double, it just assumes that such a definition is provided elsewhere and creates a reference(for the linker to resolve,linker) to that definition. On the other hand, when the compiler processes the file myfirst.cpp, it has no indication at that point that it must instantiate the template definition it contains for specific arguments.

The Inclusion Model
Rewrite the header-file, including template definition.
#ifndef?MYFIRST_HPP
#define?MYFIRST_HPP


#include?
<iostream>
#include?
<typeinfo>

//?declaration?of?template
template?<typename?T>?
void?print_typeof?(T?const&
);

//?implementation/definition?of?template

template?<typename?T>
void?print_typeof?(T?const&?x)
{
????std::cout?
<<?typeid(x).name()?<<
?std::endl;
}


#endif?//?MYFIRST_HPP
disadvantage: the cost is not the result of size of the template definition itself, but the result of the fact that we must also include the header used by the definition of our template-in the case <iostream> and <typeinfo>.\

Explicit Instantiation
To avoid above linker error we can add the following file to our program:
#include?"myfirst.cpp"

//?explicitly?instantiate?print_typeof()?for?type?double
template?void?print_typeof<double>(double?const&);
disadvantage: We must carefully keep track of which entities to instantiate. For large projects this quickly becomes an excessive burden.
advantage:
the instantiation can be tuned to the needs of the program.
The overhead of large header is avoided.
The source code of template definition can be kept hidden, but then no additional instantiations can be created by a client program.
Finally, for some applications it can be useful to control the exact location(that is, the object file)of a template instance.

Separation model

2. Usually you should use the inclusion model
3. By separating template code into different header files for declarations and definitions, you can more easily switch between the inclusion model and explicit instantiation
4. The C++ standard defines a separate compilation model for templates(using the keyword export). It is not yet widely available, however.
5. To take advantage of precompiled headers, be sure to keep the same order for #include directives.
6. Debuggin code with templates can be challenging
7. Template instances may have very long names

posted @ 2006-12-03 12:38 ningfangli 閱讀(183) | 評論 (0)編輯 收藏

網上推薦的殺毒組合

殺毒就用卡巴:(不敢恭維,原來用過,很耗資源)
木馬就用Ewido:(剛裝上,破解比較麻煩,文件中有整個包,看到大家的評價不錯,官方下載:http://download.ewido.net/ewido-setup.exe;)
防火墻就用ZoneAlarm:? (還是不用的好,這個好麻煩,總要你確認是否允許聯網,就用xp的防火墻吧)

這三個合起來用,可以使得系統堅若磐石
它們每個都是當今世界最強的,不用是你的損失!!

卡巴和ZoneAlarm同時安裝時,記得在卡巴的實時保護設置里,把那個禁止網絡攻擊保護打上鉤!!!!!!不然會沖突!!! 切記!!!(如果只安裝卡巴的話就不用這樣做了)

posted @ 2006-12-02 01:30 ningfangli 閱讀(186) | 評論 (0)編輯 收藏

不勝其煩的網絡病毒!

今天晚上,已經是我兩周以來第二次恢復筆記本的系統了,好在有true image啊!。原因都是一樣:在上網找一些軟件時,不幸中招。
我還一直很小心不斷升級Symantec。將防火墻開啟。也真不知道哪個防毒軟件真的好使,也不知道怎么這么多人希望弄這些病毒!
無奈!

posted @ 2006-12-02 00:46 ningfangli 閱讀(106) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 5

     摘要: 1. To access a type name that depends on a template parameter, you have to?qualify(?修改,修飾) the name with a leading typename//?print?elements?of?an?STL?containertemplate?<typename?T>void?printcol...  閱讀全文

posted @ 2006-12-01 15:41 ningfangli 閱讀(167) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 4

Chapter 4 Nontype Template Parameters
1. Templates can have template parameters that are values rather than types
With this class, user of the stack could specify this size of the array as the maximum size needed for stack elements
template?<typename?T,?int?MAXSIZE>
class?Stack?{
??
private:
????T?elems[MAXSIZE];????????
//?elements
????int?numElems;????????????//?current?number?of?elements

??
public:
????Stack();??????????????????
//?constructor
????void?push(T?const&);??????//?push?element
????void?pop();???????????????//?pop?element
????T?top()?const;????????????//?return?top?element
????bool?empty()?const?{??????//?return?whether?the?stack?is?empty
????????return?numElems?==?0;
????}

????
bool?full()?const?{???????//?return?whether?the?stack?is?full
????????return?numElems?==?MAXSIZE;
????}

}
;

//?constructor
template?<typename?T,?int?MAXSIZE>
Stack
<T,MAXSIZE>::Stack?()
??:?numElems(
0)???????????????//?start?with?no?elements
{
????
//?nothing?else?to?do
}


template?
<typename?T,?int?MAXSIZE>
void?Stack<T,MAXSIZE>::push?(T?const&?elem)
{
????
if?(numElems?==?MAXSIZE)?{
????????
throw?std::out_of_range("Stack<>::push():?stack?is?full");
????}

????elems[numElems]?
=?elem;???//?append?element
????++numElems;???????????????//?increment?number?of?elements
}


template
<typename?T,?int?MAXSIZE>
void?Stack<T,MAXSIZE>::pop?()
{
????
if?(numElems?<=?0)?{
????????
throw?std::out_of_range("Stack<>::pop():?empty?stack");
????}

????
--numElems;???????????????//?decrement?number?of?elements
}


template?
<typename?T,?int?MAXSIZE>
T?Stack
<T,MAXSIZE>::top?()?const
{
????
if?(numElems?<=?0)?{
????????
throw?std::out_of_range("Stack<>::top():?empty?stack");
????}

????
return?elems[numElems-1];??//?return?last?element
}
2. You can also define nontype parameters for function templates.
template?<typename?T,?int?VAL>
T?addValue?(T?
const&?x)
{
????
return?x?+?VAL;
}
However, according to the current standard, sets of overloaded functions cannot? be used for template parameter deduction. Thus, you have to cast to the exact type of the function template argument:
std::transform(source.begin(),source.end(),//?start?and?end?of?source
???????????????dest.begin(),//?start?of?destination
???????????????(int(*)(int?const&))addValue<int,5>);//operation
There is a proposal for the standard to fix this behavior so that the cast isn't necessary.
2. You cannot use floating-point numbers, class-type objects, and objects with internal linkage(such as string literals) as arguments for nontype template parameters

posted @ 2006-11-26 19:50 ningfangli 閱讀(140) | 評論 (0)編輯 收藏

斷點失效解決方法

http://www.controlav.com/bphelper/start.asp

posted @ 2006-11-26 17:02 ningfangli 閱讀(130) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 3

Chapter 3 Class Templates
1. A clas template is a class that is implemented with one or more type parameters left open
#include?<vector>
#include?
<stdexcept>

template?
<typename?T>
class?Stack?{
??
private:
????std::vector
<T>?elems;?????//?elements

??
public:
????
void?push(T?const&);??????//?push?element
????void?pop();???????????????//?pop?element
????T?top()?const;????????????//?return?top?element
????bool?empty()?const?{??????//?return?whether?the?stack?is?empty
????????return?elems.empty();
????}

}
;

template?
<typename?T>
void?Stack<T>::push?(T?const&?elem)
{
????elems.push_back(elem);????
//?append?copy?of?passed?elem
}


template
<typename?T>
void?Stack<T>::pop?()
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range("Stack<>::pop():?empty?stack");
????}

????elems.pop_back();?????????
//?remove?last?element
}


template?
<typename?T>
T?Stack
<T>::top?()?const
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range("Stack<>::top():?empty?stack");
????}

????
return?elems.back();??????//?return?copy?of?last?element
}
2. To use a class template, you pass the open types as template arguments. The class template is the instantiated(and compiled) for these types
3. For class templates, only those menber funcitons that are called are instantiated
This , of course, saves time and space. It has the additional benefit that you can instantiate a class even for those types that cannot perform all the operations of all the menber functions, as long as these member functions are not called.
Note that you have to put whitespace between the two closing? template brackets. If you don't do this, you are using operator>>,which results in a syntax error:
Stack<Stack<int>>?intStackStack;?//ERROR:>>is?not?allowed
4. You can specialize calss templates for certain types
template<>
class?Stack<std::string>?{
??
private:
????std::deque
<std::string>?elems;??//?elements

??
public:
????
void?push(std::string?const&);??//?push?element
????void?pop();?????????????????????//?pop?element
????std::string?top()?const;????????//?return?top?element
????bool?empty()?const?{????????????//?return?whether?the?stack?is?empty
????????return?elems.empty();
????}

}
;

void?Stack<std::string>::push?(std::string?const&?elem)
{
????elems.push_back(elem);????
//?append?copy?of?passed?elem
}


void?Stack<std::string>::pop?()
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range
????????????????(
"Stack<std::string>::pop():?empty?stack");
????}

????elems.pop_back();?????????
//?remove?last?element
}


std::
string?Stack<std::string>::top?()?const
{
????
if?(elems.empty())?{
????????
throw?std::out_of_range
????????????????(
"Stack<std::string>::top():?empty?stack");
????}

????
return?elems.back();??????//?return?copy?of?last?element
}


ps:也就是所謂的特定版本,模板元編程中的關鍵。
5. You can partially specialize class templates for certain types
If more than one partial specilalization matches equally well, the declaration is ambiguous
6. You can define default values for class template parameters.These may refer to previous template parameters

posted @ 2006-11-26 16:15 ningfangli 閱讀(169) | 評論 (0)編輯 收藏

"C++Templates The Complete Guide"讀書筆記----Chapter 2

這段時間在通過"C++Templates The Complete Guide"這本書學習Templates。發現這本書確實不錯:語言簡明,內容翔實。特別是每章后面的Summery總結得很好。這份讀書筆記就已這個Summery為基礎寫的。

書前面的Prefece和Chapter 1就跳過了。既然來學習Templates就已經知道它的重要性了。

??????????????????????????????? Chapter 2 FunctionTemplates
1. Function templates define a family of functions for different template arguments;

template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
// ?if?a?<?b?then?use?b?else?use?a
???? return ??a? < ?b? ? ?b?:?a;
}

2. When you pass template arguments, function templates are instantiated for these argument types.
The process of replacing templates parameters by concrete types is called instantiatin.(at compiled time)
3. You can explicitly qualify the template parameters

{
// ?because?no?automatic?type?conversion?if?allowed?in?templates,so
max(static_cast < double > ( 4 ), 4.2 ) // cast?the?arguments?so?that?they?both?match
max < double > ( 4 , 4.2 ) // ?specify?explicitly?the?type?of?T
}

4. You can overload funciton templates

inline? int ? const & ?max?( int ? const & ?a,? int ? const & ?b)?
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?two?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?three?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b,?T? const & ?c)
{
????
return ?::max?(::max(a,b),?c);
}


int ?main()
{
????::max(
7 ,? 42 ,? 68 );????? // ?calls?the?template?for?three?arguments
????::max( 7.0 ,? 42.0 );????? // ?calls?max<double>?(by?argument?deduction)
????::max( ' a ' ,? ' b ' );?????? // ?calls?max<char>?(by?argument?deduction)
????::max( 7 ,? 42 );????????? // ?calls?the?nontemplate?for?two?ints
????::max <> ( 7 ,? 42 );??????? // ?calls?max<int>?(by?argument?deduction)
????::max < double > ( 7 ,? 42 );? // ?calls?max<double>?(no?argument?deduction)
????::max( ' a ' ,? 42.7 );????? // ?calls?the?nontemplate?for?two?ints
}

ps: the overload resolution process normally prefers this nontemplate over one generated from the template. the fourth call falls under this rule.
5. When you overload function templates, limit your changes to specifying template parameters explicitly

{
max
<> ( 7 , 42 ); // call?max<int>?(by?argument?deduction)
}


6. Make sure you see all overloaded versions of funciton templates before you call them

template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b)
{
????
return ??a? < ?b? ? ?b?:?a;
}


// ?maximum?of?three?values?of?any?type
template? < typename?T >
inline?T?
const & ?max?(T? const & ?a,?T? const & ?b,?T? const & ?c)
{
????
return ?max?(max(a,b),?c);?? // ?uses?the?template?version?even?for?ints
}
?????????????????????????????? // ?because?the?following?declaration?comes
???????????????????????????????
// ?too?late:
// ?maximum?of?two?int?values
inline? int ? const & ?max?( int ? const & ?a,? int ? const & ?b)?
{
????
return ??a? < ?b? ? ?b?:?a;
}


?

posted @ 2006-11-26 15:24 ningfangli 閱讀(183) | 評論 (0)編輯 收藏

建立這個站點

? 昨天晚上建立了這個博客。主要想把關于自己學習C++的知識、人生的感悟、還有從網上看到的好東西等等都放在這里。但建立的時候為博客的名字,我和老婆絞盡腦汁。想的名字不是太俗,就是太怪。于是我們就想到問問我兩歲半的兒子,正處于睡意懵懂中的兒子大聲說:“寧帥!”。哈哈。這個是兒子給自己起的名字。好就叫這個了。至于“健康、快樂、勇敢”是我們對他的希望。

posted @ 2006-11-23 10:51 ningfangli 閱讀(121) | 評論 (0)編輯 收藏

僅列出標題
共4頁: 1 2 3 4 

導航

統計

公告

Dict.CN 在線詞典, 英語學習, 在線翻譯

常用鏈接

留言簿(4)

隨筆檔案

文章分類

文章檔案

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            国产日韩欧美综合在线| 久久国产精品亚洲77777| 亚洲视频观看| 亚洲美女av网站| 亚洲精品欧美在线| aa级大片欧美| 亚洲欧美在线另类| 欧美影院成人| 裸体歌舞表演一区二区| 欧美国产日韩一区| 99re6这里只有精品| 亚洲天堂av图片| 久久成人亚洲| 欧美精品在线视频| 国产精品欧美在线| 在线高清一区| 在线一区二区日韩| 久久久久久久91| 亚洲国产综合在线看不卡| 亚洲人成小说网站色在线| 欧美一区二区三区久久精品茉莉花 | 亚洲综合欧美| 久久午夜电影网| 欧美视频在线观看免费网址| 国产女人aaa级久久久级| 亚洲精品久久久久久久久| 羞羞视频在线观看欧美| 亚洲国产精品久久久久| 香蕉成人久久| 国产精品vvv| 亚洲巨乳在线| 蜜臀91精品一区二区三区| 一区二区av| 欧美激情在线狂野欧美精品| 国产一区二区久久久| 亚洲影视九九影院在线观看| 欧美国产在线电影| 久久久久久精| 国产欧美精品一区| 一区二区三区欧美成人| 欧美高清在线视频| 久久se精品一区二区| 欧美午夜国产| 日韩亚洲在线观看| 欧美成人有码| 久久免费视频在线| 国产自产2019最新不卡| 久久激情五月丁香伊人| 亚洲欧美三级伦理| 国产精品美女主播| 亚洲男女自偷自拍| 亚洲视频图片小说| 国产精品v亚洲精品v日韩精品 | 亚洲视频精品在线| 欧美另类综合| 99ri日韩精品视频| 91久久久久久| 欧美精品久久久久久久久老牛影院| 亚洲高清123| 欧美国产一区视频在线观看 | 欧美高清不卡| 亚洲精品在线三区| 亚洲国产毛片完整版 | 国产精品亚洲一区二区三区在线| 国产精品99久久久久久久vr| 亚洲人成在线播放| 欧美日韩一级黄| 亚洲欧美日韩精品在线| 亚洲线精品一区二区三区八戒| 国产精品高清在线| 欧美成人精品激情在线观看| 国产麻豆综合| 亚洲一区二区高清| 亚洲女同精品视频| 国模私拍一区二区三区| 男女精品网站| 欧美黄色免费网站| 亚洲免费中文字幕| 久久精品国产免费观看| 亚洲国产精品精华液网站| 亚洲国产日韩欧美在线图片| 欧美1区2区3区| 亚洲午夜一级| 欧美在线观看天堂一区二区三区| 一区二区在线免费观看| 亚洲国产欧美日韩精品| 国产精品ⅴa在线观看h| 久久久久看片| 欧美日韩午夜剧场| 久久亚洲综合网| 欧美伦理视频网站| 久久精品视频免费播放| 欧美精品电影在线| 久久久久欧美| 欧美色大人视频| 老司机精品福利视频| 欧美日韩一二三四五区| 老司机67194精品线观看| 欧美日韩另类视频| 欧美va天堂va视频va在线| 欧美午夜精品一区| 亚洲电影专区| 韩国欧美国产1区| 99精品欧美一区| 亚洲国产精品一区制服丝袜 | 91久久精品一区二区别| 亚洲深夜影院| 一区二区三区 在线观看视频| 久久国产乱子精品免费女| 制服丝袜亚洲播放| 免费的成人av| 久久亚洲春色中文字幕| 国产精品欧美一区喷水| 亚洲精品视频在线观看免费| 亚洲第一在线视频| 欧美在线免费视频| 午夜国产不卡在线观看视频| 欧美精品三级日韩久久| 欧美成人精品| 影音先锋一区| 久久国产一区| 久久人人九九| 韩日在线一区| 久久爱www.| 久久久亚洲人| 激情成人综合| 久久九九电影| 美女精品在线| 影音先锋另类| 久久综合五月天婷婷伊人| 美女主播一区| 亚洲电影有码| 暖暖成人免费视频| 亚洲国产成人午夜在线一区| 欧美激情视频免费观看| 永久免费毛片在线播放不卡| 亚洲欧美久久久| 欧美综合国产| 狠狠色狠狠色综合| 久久免费视频在线| 欧美激情第3页| 亚洲精品免费电影| 欧美精品粉嫩高潮一区二区| 亚洲精品国产无天堂网2021| 在线亚洲成人| 国产精品每日更新在线播放网址| 亚洲午夜激情免费视频| 欧美一区二区在线免费播放| 国产日韩欧美a| 久久网站热最新地址| 亚洲国产精品一区二区久| 亚洲伦理网站| 国产精品美女久久久久久久 | 国产在线拍揄自揄视频不卡99| 欧美亚洲视频在线看网址| 久久深夜福利| 亚洲精品美女久久7777777| 欧美日韩国产成人精品| 亚洲影院在线| 免费亚洲电影在线| 在线视频日韩| 国内揄拍国内精品久久| 欧美激情一二区| 亚洲欧美日韩国产另类专区| 久久综合久久综合这里只有精品 | 欧美在线视频观看免费网站| 亚洲成人在线网| 欧美视频一区二区三区…| 欧美尤物巨大精品爽| 亚洲国产天堂久久国产91| 午夜精品国产更新| 亚洲国产精品电影| 国产精品乱子久久久久| 狼人天天伊人久久| 亚洲小说欧美另类婷婷| 欧美777四色影视在线| 亚洲综合精品自拍| 亚洲欧洲一区二区三区在线观看 | 欧美成人午夜| 亚洲自拍电影| 亚洲激情成人网| 久久午夜精品一区二区| 在线亚洲一区观看| 亚洲激情成人在线| 国产一区二区三区久久| 欧美日韩一区二区免费在线观看| 久久精品一区中文字幕| 亚洲小说欧美另类社区| 亚洲精选大片| 欧美福利精品| 久久久精彩视频| 亚洲欧美国产77777| 亚洲精品综合精品自拍| 黄色亚洲精品| 国产一区二区三区丝袜| 国产精品日韩欧美大师| 欧美手机在线| 欧美日韩国产影片| 欧美极品在线播放| 欧美v国产在线一区二区三区|